function fbconnect_register_page in Facebook Connect 6.2
Same name and namespace in other branches
- 5 fbconnect.module \fbconnect_register_page()
- 6 fbconnect.pages.inc \fbconnect_register_page()
Menu callback. Called when user perform facebook registration
1 string reference to 'fbconnect_register_page'
- fbconnect_menu in ./
fbconnect.module - Implements hook_menu().
File
- ./
fbconnect.pages.inc, line 52 - User pages callbacks for the fbconnect module.
Code
function fbconnect_register_page($form_state = array()) {
$conf = fbconnect_get_config();
$data = fbconnect_get_user_info('name, email');
$form = drupal_retrieve_form('user_register', $form_state);
$site = $conf['invite_name'];
// #758918: prevent users registration if admin has blocked free registration.
$user_reg_mode = variable_get('user_register', 1);
if ($user_reg_mode == 0) {
drupal_access_denied();
return;
}
drupal_prepare_form('user_register', $form, $form_state);
$form['name']['#default_value'] = $data['name'];
$form['fbconnect'] = array(
'#type' => 'fieldset',
'#title' => t('Facebook Connect'),
);
$form['fbconnect']['fb_visible'] = array(
'#type' => 'checkbox',
'#title' => t('Let my Facebook friends see me on @sitename', array(
'@sitename' => $site,
)),
'#default_value' => 1,
);
if (variable_get('user_pictures', 0) && $conf['user_pictures'] == 'allow') {
$form['fbconnect']['fb_avatar'] = array(
'#type' => 'checkbox',
'#title' => t('Use my Facebook picture as user picture'),
'#description' => t('Your picture will be loaded from facebook.'),
'#default_value' => 1,
);
}
$form['#redirect'] = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';
$form['#submit'][] = 'fbconnect_register_form_submit';
// Fast registration mode, we by pass std drupal reg form.
if ($conf['fast_reg_mode']) {
$newname = $conf['fast_reg_autoname'] ? _fbconnect_get_username($data['name']) : $data['name'];
$form_state['values']['name'] = $newname;
$form_state['values']['mail'] = $data['email'];
$form_state['values']['pass'] = user_password();
$form_state['values']['status'] = 1;
$form_state['values']['fb_visible'] = 1;
$form_state['values']['fb_avatar'] = 1;
drupal_validate_form('user_register', $form, $form_state);
$success = !form_get_errors();
if (!$success) {
$dest = array(
'query' => 'destination=fbconnect/link',
);
drupal_set_message(t('Facebook connect registration failed for the reasons listed. You may register now, or if you already have an account you can <a href="@login">log in</a> now and link your account', array(
'@login' => url('user/login', $dest),
)), 'warning');
// Append form validation errors below the above warning.
$messages = drupal_get_messages('error');
foreach ($messages['error'] as $message) {
drupal_set_message($message, 'error');
}
drupal_goto('user/register', $dest['query']);
}
fbconnect_register_form_submit($form, $form_state);
drupal_goto();
}
return $form;
}