function twitter_signin_form_alter in Twitter 7.6
Same name and namespace in other branches
- 6.5 twitter_signin/twitter_signin.module \twitter_signin_form_alter()
- 6.3 twitter_signin/twitter_signin.module \twitter_signin_form_alter()
- 6.4 twitter_signin/twitter_signin.module \twitter_signin_form_alter()
- 7.3 twitter_signin/twitter_signin.module \twitter_signin_form_alter()
- 7.4 twitter_signin/twitter_signin.module \twitter_signin_form_alter()
- 7.5 twitter_signin/twitter_signin.module \twitter_signin_form_alter()
Implements hook_form_alter().
File
- twitter_signin/
twitter_signin.module, line 121 - Hook implementations for Twitter Signin module.
Code
function twitter_signin_form_alter(&$form, $form_state, $form_id) {
// By default don't do anything when the site is in maintenance mode, but
// allow this to be changed so that admins can still login.
if (defined('MAINTENANCE_MODE') && !variable_get('twitter_signin_maintenance_mode', FALSE)) {
return;
}
if ($form_id == 'twitter_oauth_callback_form' && isset($_SESSION['twitter_oauth']['signin'])) {
$form['#submit'] = array_merge(array(
'twitter_signin_oauth_callback_submit',
), $form['#submit']);
}
// Don't do anything else if the credentials haven't been set up yet.
$key = variable_get('twitter_consumer_key', '');
$secret = variable_get('twitter_consumer_secret', '');
if (empty($key) || empty($secret)) {
return;
}
// Login forms.
if ($form_id == 'user_login' || $form_id == 'user_login_block') {
if (variable_get('twitter_signin_login', TRUE)) {
$items = array();
$items[] = twitter_signin_button();
$form['twitter_signin'] = array(
'#theme' => 'item_list',
'#items' => $items,
'#attributes' => array(
'class' => array(
'twitter_signin',
),
),
);
}
}
elseif ($form_id == 'user_register_form' && isset($_SESSION['twitter']['values'])) {
$form['account']['name']['#default_value'] = $_SESSION['twitter']['values']['screen_name'];
$form['auth_twitter'] = array(
'#type' => 'hidden',
'#value' => $_SESSION['twitter']['values']['user_id'],
);
}
}