How to Add a User to a WordPress Multisite Via Database as an Administrator

WP_MultiSiteA while back we were given permission to host and edit a clients’ website, built on WordPress with Multisite functionality. However, for various reasons we were unable to get in touch with the previous developer who had Admin access to the sites. Since we were hosting their website and database, we at least had that. The solution then was to add a new user (us) through the back-end. The question that remained was, how?

Here is what we did:

1. Access the database

Once the database was created and uploaded, we needed to access it. Our personal favourite desktop tool for the job is HeidiSQL.

2. Add a new user

To do this, go to the wp_users table. From there, you can add your username, user_nicename, email, etc.

The password though is a bit tricky. Assuming that the encryption is a standard MD5 Hash and not with SALT, you can insert a password (say it’s 123456) as follows:

"Update [table_prefix - usually wp_]users set user_pass=md5('123456') where ID=[id # of user you are trying to update];"

1 - add user info without password

3. Add User to sites

Now that the basic user information is added, now we need to associate it with a site. To do so you would add the following fields:

  • wp_capabilities -> a:1:{s:13:”administrator”;s:1:”1″;}
  • wp_user-settings -> editor=tinymce&mfold=o&align=center&libraryContent=browse&urlbutton=custom&imgsize=full
  • wp_user_level -> 10

Do this for all sites, wp_, wp_1_. wp_2_, wp_3, etc.

2 - usermeta convention

4. Add Site Admins in wp_sitemeta

Okay, great. Now you have added yourself as an admin for each sites. However, you still aren’t yet set to change Network Settings. For this, you need to go to [table_prefix – usually wp_]sitemeta. From there search for a meta_key called “site_admins.” The syntax is in the screenshot below. Let’s analyze the syntax.

a:3:{i:0;s:5:"admin";i:1;s:9:"user12345";i:2;s:10:"user234567";}

  • “a:3″ -> for network Admins, there will be 3. The succeeding text will now list them.
  • “i:0″, “i:1″, ”i:2″ -> This is the user order: Admin1, Admin2, Admin3, etc.
  • “s:5″, “s:9″, “s:10” -> This represents the number of characters of the declared username! This apparently was added as a security feature of sorts. If the number of characters are off than this will not work!
  • “admin,” “irisemedia,” etc. -> This is the declared username that will be associated with the Network Admins

3 - sitemeta convention

Now, try logging in and see if it works.

Post originally published here: http://www.irisemedia.com/blog/2013/04/30/how-to-add-a-user-to-a-wordpress-multisite-via-database-as-an-administrator.html

Comments

comments

Recent Posts