9

I am working on getting a copy of a WordPress MU network up and running on my local machine for development purposes (using WordPress 3.2.1 at the moment). I need access to the network administration options.

In the usermeta table, I changed my user-level to 10 and capabilities to a:1:{s:13:"administrator";b:1;}

In the sitemeta table, I added myself to the serialized array of users in the site_admins option.

While this did get me access to the generic wp-admin page, I still do not have access to any of the network admin options (such as automatic upgrade for WP, plugins, or themes, etc).

6

So, it turns out that those three changes were all that were needed. It also turns out that if any of the serialized arrays are modified incorrectly (which is easy to do when modifying them by hand), the system will just assume you are not a network administrator.

Correcting the serialized array for the site_admins option fixed the problem.

4
  • 1
    For anyone else that comes here and is confused by the rather confusing format of PHP serialized arrays, there's a passable explanation available here: php.net/manual/en/function.serialize.php#66147 Jan 7 '13 at 4:41
  • 2
    Important to note that the site_admins meta is case sensitive. I spent an hour before I realised my username had an uppercase character.
    – John Reid
    Nov 3 '14 at 14:06
  • 1
    One easy mistake is forgetting about trailing semicolon ; in site_admins serialized array.
    – jmarceli
    Jan 2 '17 at 23:17
  • Worth noting that if you're planning on doing it by hand you could use unserialize and serialize functions by starting a php -a session. Or you could use online tools like this: php.fnlist.com/php/unserialize or php.fnlist.com/php/serialize then copy and paste the database version (e.g. a:1:{s:13:"administrator";b:1;}) into the unserialize tool, update the result by adding/removing/editing the array structure (because its easier), then use the serialize tool to convert it back again. Causes less margin for error.
    – hazrpg
    Jun 20 '18 at 10:25
4

If you can connect via SSH, you can also add super-admin rights to existing user with WP-CLI by running command wp super-admin add <username> on the server.

As you are running a copy of the website in your local machine. Open your terminal, install WP-CLI globally and once it's installed, go to your website folder and type: wp super-admin add <username>.

I hope it helps.

1

Just in case the format for the serialised array in meta_value where meta_key='site_admins' in the sitemeta table isn't clear to someone (like it wasn't clear to me).

a:5:{i:0;s:5:"admin";i:1;s:9:"user12345";i:2;s:4:"user";i:3;s:5:"user1";i:4;s:8:"user1234";}

a:5 at the beginning of the array indicates that the array has five elements.

Each element's length is also indicated by s:x, where x is the length of the array element. For example, the admin username length is shown by s:5

0

Here is the queries to create a new admin user :

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', MD5('pass123'), 'firstname lastname', 'email@example.com', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');


INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

It will definitly help you. :)

1
  • Could you add some explanation what that does. Just dropping code/SQL queries without any explanation isn't very helpful for people.
    – kraftner
    Jul 4 '17 at 14:09
0

I had been struggling with this issue for days, ie. When I updated the domain name of my main network site, the network admin option disappeared from the dashboard. Tried to look all over the place. Finally ended up on this question and once I read locoMotion's explanation of what the fields in sitemeta table mean, I noticed that the length of the username for the superadmin was not correct. When I fixed that, the SiteAdmin menu started showing up on the dashboard again. Thanks @quadium32 for asking this question and special thanks @locoMotion for explaining what the sitemeta values mean. Best Regards. Tariq

0

the other dude mysql query doesnt work and doesnt make you a network super admin, but this one does!

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `user_registered`) VALUES ('newadmin', MD5('password1234567890change_me'), 'firstname lastname', 'email@example.com', '0', NOW());

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

INSERT INTO `wp_sitemeta` ( `site_id`, `meta_key`, `meta_value`  ) VALUES (1, 'site_admins', 'a:1:{i:0;s:8:"newadmin";}' );

now explaining this:

the most trickiest part for a super admin is the last query!

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

To learn more about this read more here

Note: change the password!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.