You are here

function realname_registration_validate in Realname registration 6.2

Same name and namespace in other branches
  1. 6 realname_registration.module \realname_registration_validate()
  2. 7.2 realname_registration.module \realname_registration_validate()
  3. 7 realname_registration.module \realname_registration_validate()

realname_registration_validate() is an optional field validator for for real names.

See also

user_register_form()

user_register_submit()

1 string reference to 'realname_registration_validate'
realname_registration_form_alter in ./realname_registration.module
Implementation of hook_form_alter().

File

./realname_registration.module, line 124
For using real names during registration.

Code

function realname_registration_validate($form, &$form_state) {
  $c = realname_registration_load_settings();

  // A first name may not contain symbols or numbers.
  $fname = $c->fname->use_content_profile ? $form_state['content_profile_registration'][$c->fname->content_node]['node']->{$c->fname->field}[0]['value'] : $form_state['values'][$c->fname->field];
  if (!preg_match("/^[-\\pL']*\$/u", $fname)) {
    form_set_error($c->fname->field, t('First name may not contain symbols or numbers.'));
  }

  // A middle name may not contain symbols or numbers. This field is optional.
  if ($c->mname->field) {
    $mname = $c->mname->use_content_profile ? $form_state['content_profile_registration'][$c->mname->content_node]['node']->{$c->mname->field}[0]['value'] : $form_state['values'][$c->mname->field];
    if (!preg_match("/^[-\\pL']*\$/u", $mname)) {
      form_set_error($c->mname->field, t('Middle name may not contain symbols or numbers.'));
    }
  }

  // A last name may not contain symbols or numbers.
  $lname = $c->lname->use_content_profile ? $form_state['content_profile_registration'][$c->lname->content_node]['node']->{$c->lname->field}[0]['value'] : $form_state['values'][$c->lname->field];
  if (!preg_match("/^[-\\pL']*\$/u", $lname)) {
    form_set_error($c->lname->field, t('Last name may not contain symbols or numbers.'));
  }
}