function social_user_register_validate in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.2 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.3 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.4 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.5 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.6 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.7 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 8.8 modules/social_features/social_user/social_user.module \social_user_register_validate()
- 10.3.x modules/social_features/social_user/social_user.module \social_user_register_validate()
- 10.1.x modules/social_features/social_user/social_user.module \social_user_register_validate()
- 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 240 - The social user module alterations.
Code
function social_user_register_validate(&$form, FormStateInterface $form_state) {
// Fetch input.
$input = $form_state
->getValues();
// Check if user data with the input can be found.
$mail_exists = user_load_by_mail($input['mail']);
$name_exists = user_load_by_name($input['name']);
// Check if mail or username already exist.
if ($mail_exists || $name_exists) {
// 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();
// Check if the email address already exist. Set a generic message
// regarding the problem.
if ($mail_exists) {
$form_state
->setErrorByName('mail', t("Due to privacy concerns, we can't disclose the existence of registered email addresses. Please make sure the email address is entered correctly and try again."));
}
// Check if the username already exist. Set a generic message regarding
// the problem.
if ($name_exists) {
$form_state
->setErrorByName('name', t('The entered username already exists or has an incorrect format. Please try again.'));
}
}
}