You are here

function signup_form_validate_username in Signup 6

Same name and namespace in other branches
  1. 5.2 signup.module \signup_form_validate_username()
  2. 6.2 includes/signup_form.inc \signup_form_validate_username()
  3. 7 includes/signup_form.inc \signup_form_validate_username()

Validates the username on the admin form to signup another user.

Parameters

$form: Form array for the username field.

$nid: Node id of the node the user is being signed up for.

1 string reference to 'signup_form_validate_username'
signup_form in includes/signup_form.inc
Build the user signup form.

File

includes/signup_form.inc, line 178
Code for the form when users sign up.

Code

function signup_form_validate_username($form, $form_state) {
  $nid = $form_state['values']['nid'];
  $username = $form_state['values']['signup_username'];
  $account = user_load(array(
    'name' => $username,
  ));
  if (empty($account)) {
    form_set_error('signup_username', t('User %user_name does not exist.', array(
      '%user_name' => $username,
    )));
  }
  elseif (db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE uid = %d AND nid = %d", $account->uid, $nid)) > 0) {
    $node = node_load($nid);
    form_set_error('signup_username', t('User !user is already signed up for %title', array(
      '!user' => theme('username', $account),
      '%title' => $node->title,
    )));
  }
}