You are here

function social_user_register_validate in Open Social 8.2

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user/social_user.module \social_user_register_validate()
  2. 8 modules/social_features/social_user/social_user.module \social_user_register_validate()
  3. 8.3 modules/social_features/social_user/social_user.module \social_user_register_validate()
  4. 8.4 modules/social_features/social_user/social_user.module \social_user_register_validate()
  5. 8.5 modules/social_features/social_user/social_user.module \social_user_register_validate()
  6. 8.6 modules/social_features/social_user/social_user.module \social_user_register_validate()
  7. 8.7 modules/social_features/social_user/social_user.module \social_user_register_validate()
  8. 8.8 modules/social_features/social_user/social_user.module \social_user_register_validate()
  9. 10.3.x modules/social_features/social_user/social_user.module \social_user_register_validate()
  10. 10.0.x modules/social_features/social_user/social_user.module \social_user_register_validate()
  11. 10.1.x modules/social_features/social_user/social_user.module \social_user_register_validate()
  12. 10.2.x modules/social_features/social_user/social_user.module \social_user_register_validate()

Validate function for the user register form.

1 string reference to 'social_user_register_validate'
social_user_form_user_register_form_alter in modules/social_features/social_user/social_user.module
Implements hook_form_FORM_ID_alter().

File

modules/social_features/social_user/social_user.module, line 48
The social user module alterations.

Code

function social_user_register_validate(&$form, FormStateInterface $form_state) {

  // Fetch input.
  $input = $form_state
    ->getValues();

  // Check if mail or username already exist.
  if (user_load_by_mail($input['mail']) || user_load_by_name($input['name'])) {

    // If either the username or mail already exists in the DB, we clear ALL
    // existing messages, making sure nothing about this is being disclosed.
    $form_state
      ->clearErrors();

    // Set a new more general error.
    $form_state
      ->setErrorByName('mail', t('Due to privacy concerns, the policy of this web site is not to disclose the existence of registered email addresses or usernames. However, if you entered an email address or username that already exists, you will not be able to continue.
    Please try again, or request a new password. Contact the site administrator if there are any problems.'));
  }
}