最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

capabilities - How can I promote a user to a network administrator?

programmeradmin1浏览0评论

I took over an existing multisite network and I don't have the privileges to promote anyone to network admin through the WP Admin UI directly. How can I promote my site administrator to network admin via MySQL and/or WP CLI?

I took over an existing multisite network and I don't have the privileges to promote anyone to network admin through the WP Admin UI directly. How can I promote my site administrator to network admin via MySQL and/or WP CLI?

Share Improve this question asked Feb 7, 2017 at 22:17 acobsteracobster 1231 silver badge10 bronze badges 6
  • you want to create a Network Admin (aka Super Admin) ? – Arsalan Mithani Commented Feb 7, 2017 at 22:34
  • no, I want to promote an existing admin to Super Admin – acobster Commented Feb 7, 2017 at 22:40
  • 2 Possible duplicate of Add Wordpress MU Network Admin via Database – acobster Commented Feb 7, 2017 at 23:03
  • then why did you asked? Use google first, that's what recommended here! – Arsalan Mithani Commented Feb 7, 2017 at 23:05
  • Understood, I got linked to the other question from WP IRC after posting this one – acobster Commented Feb 7, 2017 at 23:06
 |  Show 1 more comment

3 Answers 3

Reset to default 2

You might use grant_super_admin()

To add an admin by user ID you can use grant_super_admin. Simple put grant_super_admin in your theme’s functions.php file (usually in /wp-content/themes/CURRENT THEME NAME/functions.php). You’ll need to put the ID of the user as a variable, the example below we’re using the user ID of 1.

grant_super_admin(1);

https://drawne/add-super-admin-wordpress-network/

Or Some variation of this should do the trick:

INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', '[email protected]', 'http://www.test/', '2011-06-07 00:00:00', '', '0', 'Your Name');


INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');



INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');

http://www.wpbeginner/wp-tutorials/how-to-add-an-admin-user-to-the-wordpress-database-via-mysql/

If you have access to the command line and can use wp-cli, then you need to run two commands (assuming your site ID is 1):

wp network meta get 1 site_admins

This will return an array of all the site admins. Here is a sample array:

array (
  0 => 'user',
  1 => 'tedmasterweb',
  2 => 'fredflintston',
  3 => 'jcollins',
)

You then need to execute the following command setting the key as 4 (one more than the highest number in the array above), e.g.:

wp network meta patch insert 1 site_admins 4 myusername

You might then need to log out and log back in to see the change.

Related documentation

https://developer.wordpress/cli/commands/network/meta/update/

Can you see this in user edit?

发布评论

评论列表(0)

  1. 暂无评论