You are here

function rb_user_condition_username_is_valid in Rules Bonus Pack 6

Action for 'rb_user_condition_username_is_valid'.

File

./rb_user.module, line 131
Functions for extending user management with Rules.

Code

function rb_user_condition_username_is_valid($settings) {

  // Run the name validation function and see it it returns some kind of error
  // message. If so, the user name is invalid.
  if (user_validate_name($settings['username']) != NULL) {
    return FALSE;
  }

  // If we should check for availability, do that too.
  if (user_load(array(
    'name' => $settings['username'],
  ))) {

    // Name exists in the user table and is thus not available.
    return FALSE;
  }

  // If nothing else, this name should really be ok.
  return TRUE;
}