WordPress.org

Forums

Multiple usernames for the same account (3 posts)

  1. scyberia
    Member
    Posted 2 years ago #

    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.

  2. linux4me2
    Member
    Posted 2 years ago #

    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.

  3. bcworkz
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic