5

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).

4

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.

  • 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 – Tobias Cohen 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
0

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. :)

  • 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

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.