Add WordPress MU Network Admin via Database

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;}

Read More

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

Related posts

Leave a Reply

7 comments

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

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

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

  4. 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!

  5. 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. 🙂

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