• I would like to have four different usernames for the same administrator account so that I can “reserve” them (ex: admin, administrator).

    Which database do I have to edit; or can someone provide psuedo-code?

    I’m unfamiliar with WordPress in general.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I haven’t seen anything regarding having multiple user names for the same account. You could create different admin accounts for each of the names you want to reserve, or you could install a plugin like Restrict Usernames to prevent users from using the names you want to reserve.

    Moderator bcworkz

    (@bcworkz)

    You can’t assign multiple names for one user. A dirty hack would be to create a bunch of unused dummy accounts with no capabilities simply to reserve names.

    A more elegant solution would be to hook filters for various fields and apply a blacklist of certain names. The filters are invoked from the insert_user() definition in wp-includes/user.php. This php example should work:

    add_filter('pre_user_login', 'scy_check_names');
    add_filter('pre_user_nicename', 'scy_check_names');
    add_filter('pre_user_nickname', 'scy_check_names');
    function scy_check_names($provisional) {
      $black = array('administrator','admin','editor','moderator','mod','cialis');
      if (in_array($provisional,$black)) wp_die('Invalid name, try something different');
      return $provisional;
    }

    This isn’t very elegant either, but gets the job done. You could use regular expressions to capture more variations like “adm1n” or “_admin_”. The error handling could certainly be improved. It’s a start.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple usernames for the same account’ is closed to new replies.