Friday, 26 April 2013

WordPress: manually grant superadmin rights

Network / Super-admin privileges lost after renaming account

This article will explain how to recover lost super-admin / network privileges upon renaming account or how to manually grant super-admin privileges on a WordPress multisite, by updating the database (with phpMyAdmin or any other database gui).

First off you'll need the username of the account in question so you'll head off to "wp_users" table to get it. You can either browse through the list of usernames or run the following MySQL Query:
  • "SELECT * FROM  `wp_users`";
Get the user names ("user_login" value) from table "wp_users"
Get the user names ("user_login" value) from table "wp_users"

Now that you have the user name ("user_login" value) you'll need to add it to the super admins list.
Run the following MySQL Query to get the record responsible for that:

  • "SELECT * FROM `wp_sitemeta` WHERE `meta_key` = 'site_admins'";
You should then see something similar to this:
Grant a user super-admin rights by updating the table "wp_sitemeta"
Grant a user super-admin rights by updating the table "wp_sitemeta"

The value for the "meta_value" field is a jSON formatted array and follows this logic:
  • a:1:{i:0;s:4:"user";}
  • a:2:{i:0;s:5:"admin";s:9:"user_name";}
  • a:3:{i:0;s:8:"almighty";i:1;s:8:"xxxxxxxxx";i:2;s:10:"xxxxxxxxxx";}
where
  • in <a:X>, X is the number of usernames in the array
  • in <i:X>, X is the incremental value in the array (first one is 0, second is 1, so forth)
  • in <s:X:"username">, X is the number or characters in username

Make sure not to add spaces and use the correct upper/lower case value for the username. Also you'll most likely need to log off and then log back into your account for changes to take effect.


Good luck!


http://codex.wordpress.org/Database_Description#Multisite_Table_Overview


Post a Comment

search blog

Tricouri Personalizate si Cadouri Haioase - Tu.ro

magazin tricouri