function fbconnect_form_alter in Facebook Connect 6.2
Same name and namespace in other branches
- 5 fbconnect.module \fbconnect_form_alter()
- 6 fbconnect.module \fbconnect_form_alter()
Impletementation of hook_form_alter().
File
- ./
fbconnect.module, line 180 - Integration with Facebook Connect API.
Code
function fbconnect_form_alter(&$form, $form_state, $form_id) {
if (isset($form['account'])) {
$form['account']['mail']['#maxlength'] = 320;
}
switch ($form_id) {
case 'user_login':
if (@$_REQUEST['destination'] == 'fbconnect/link') {
drupal_set_message(t('Please log in, in order to link your account with Facebook Connect'));
$form['#submit'][] = 'fbconnect_redirect_submit';
}
// Don't break here since we want to run the next user_login_block case
// too
// Render fbconnect on login block.
case 'user_login_block':
if (@$_REQUEST['destination'] == 'fbconnect/link') {
drupal_set_message(t('Please log in, in order to link your account with Facebook Connect'));
$form['#submit'][] = 'fbconnect_redirect_submit';
}
if ((empty($_GET['destination']) || !empty($_GET['destination']) && $_GET['destination'] != 'fbconnect/link') && fbconnect_facebook_client()) {
$attr = array(
'scope' => 'email',
);
$form['fbconnect_button'] = array(
'#type' => 'item',
'#description' => t('Sign in using Facebook'),
'#value' => fbconnect_render_button($attr),
'#weight' => 1,
'#id' => 'fbconnect_button',
);
}
break;
case 'user_profile_form':
if (variable_get('user_pictures', 0) && isset($form['_account'])) {
$account = $form['_account']['#value'];
if ($account->fb_avatar && isset($form['picture'])) {
$form['picture']['fb_avatar'] = array(
'#value' => t('You are currently using your Facebook picture, if you delete or load a new picture, your facebook picture will no longer be updated.'),
'#weight' => 0,
);
$form['#submit'][] = 'fbconnect_user_edit_submit';
}
}
break;
}
}