function openid_form_user_register_form_alter
openid_form_user_register_form_alter(&$form, &$form_state)
Implements hook_form_FORM_ID_alter().
Prefills the login form with values acquired via OpenID.
File
- modules/openid/openid.module, line 182
- Implement OpenID Relying Party support for Drupal
Code
function openid_form_user_register_form_alter(&$form, &$form_state) { if (isset($_SESSION['openid']['response'])) { module_load_include('inc', 'openid'); $response = $_SESSION['openid']['response']; // Extract Simple Registration keys from the response. We only include // signed keys as required by OpenID Simple Registration Extension 1.0, // section 4. $sreg_values = openid_extract_namespace($response, OPENID_NS_SREG, 'sreg', TRUE); // Extract Attribute Exchanges keys from the response. We only include // signed keys. This is not required by the specification, but it is // recommended by Google, see // http://googlecode.blogspot.com/2011/05/security-advisory-to-websites-using.html $ax_values = openid_extract_namespace($response, OPENID_NS_AX, 'ax', TRUE); if (!empty($sreg_values['nickname'])) { // Use the nickname returned by Simple Registration if available. $form['account']['name']['#default_value'] = $sreg_values['nickname']; } elseif ($ax_name_values = openid_extract_ax_values($ax_values, array('http://axschema.org/namePerson/friendly', 'http://schema.openid.net/namePerson/friendly'))) { // Else, use the first nickname returned by AX if available. $form['account']['name']['#default_value'] = current($ax_name_values); } else { $form['account']['name']['#default_value'] = ''; } if (!empty($sreg_values['email'])) { // Use the email returned by Simple Registration if available. $form['account']['mail']['#default_value'] = $sreg_values['email']; } elseif ($ax_mail_values = openid_extract_ax_values($ax_values, array('http://axschema.org/contact/email', 'http://schema.openid.net/contact/email'))) { // Else, use the first nickname returned by AX if available. $form['account']['mail']['#default_value'] = current($ax_mail_values); } // If user_email_verification is off, hide the password field and just fill // with random password to avoid confusion. if (!variable_get('user_email_verification', TRUE)) { $form['account']['pass']['#type'] = 'hidden'; $form['account']['pass']['#value'] = user_password(); } $form['openid_claimed_id'] = array( '#type' => 'value', '#default_value' => $response['openid.claimed_id'], ); $form['openid_display'] = array( '#type' => 'item', '#title' => t('Your OpenID'), '#description' => t('This OpenID will be attached to your account after registration.'), '#markup' => check_plain($response['openid.claimed_id']), ); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!openid!openid.module/function/openid_form_user_register_form_alter/7.x