diff --git a/contrib/fb_registration.module b/contrib/fb_registration.module index acc1083db4839e72860de122cc450c13e51026d8..0c7b1ceb73dcc14048dcc009079819a4152b1d9d 100644 --- a/contrib/fb_registration.module +++ b/contrib/fb_registration.module @@ -31,6 +31,9 @@ function _fb_registration_form_alter_fields(&$form) { } } +/** + * Implements hook_form_alter(). + */ function fb_registration_form_alter(&$form, &$form_state, $form_id) { if (!isset($GLOBALS['_fb'])) { @@ -38,9 +41,12 @@ function fb_registration_form_alter(&$form, &$form_state, $form_id) { return; } + if ($GLOBALS['user']->uid) { + // No need to alter user add form. + return; + } if ($form_id == 'user_register') { - // Replace regular form with fb_registration. $form['#fb_registration'] = TRUE; @@ -48,8 +54,6 @@ function fb_registration_form_alter(&$form, &$form_state, $form_id) { _fb_registration_form_alter_fields($form); } - - if (isset($form['#fb_registration'])) { // Registration has been enabled for this form. @@ -173,7 +177,7 @@ function _fb_registration_extract_fb_fields(&$fb_fields, &$form) { 'name' => $key, 'type' => 'checkbox', 'description' => $form[$key]['#title'], - 'default' => $form[$key]['#default_value'], + 'default' => isset($form[$key]['#default_value']) ? $form[$key]['#default_value'] : NULL, ); } elseif ($form[$key]['#type'] == 'select') { diff --git a/fb_user.module b/fb_user.module index 4737071839af6bec97a23f9a07fe15e484326515..686c3f2c6c208b815fc33cb638d7c6e4632bf1e7 100644 --- a/fb_user.module +++ b/fb_user.module @@ -488,9 +488,10 @@ function fb_user_form_alter(&$form, &$form_state, $form_id) { // Add name and email to some forms. if (isset($GLOBALS['_fb'])) { $fb = $GLOBALS['_fb']; - if (($form_id == 'user_register' && variable_get(FB_USER_VAR_ALTER_REGISTER, TRUE)) || - ($form_id == 'user_login' && variable_get(FB_USER_VAR_ALTER_LOGIN, TRUE)) || - ($form_id == 'user_login_block' && variable_get(FB_USER_VAR_ALTER_LOGIN_BLOCK, TRUE))) { + if (!$GLOBALS['user']->uid && // No alters to user add form. + (($form_id == 'user_register' && variable_get(FB_USER_VAR_ALTER_REGISTER, TRUE)) || + ($form_id == 'user_login' && variable_get(FB_USER_VAR_ALTER_LOGIN, TRUE)) || + ($form_id == 'user_login_block' && variable_get(FB_USER_VAR_ALTER_LOGIN_BLOCK, TRUE)))) { if ($fbu = fb_facebook_user()) { // Facebook user has authorized app.