Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add super-admin #7

Closed
jimboobrien opened this issue Jul 26, 2017 · 6 comments
Closed

Cannot add super-admin #7

jimboobrien opened this issue Jul 26, 2017 · 6 comments

Comments

@jimboobrien
Copy link

jimboobrien commented Jul 26, 2017

Hello,

I'm setting up a VVV environment on vagrant, and I'm running into issues with not being able to add my user as a super admin to see network screens in the wp admin screens.

I have used the following line to create a multisite-install using wp cli:

wp --allow-root core multisite-install --url="http://vvv.cdc.gov" --quiet --title="CDC VVV" --admin_name=admin --admin_user="admin" --admin_email="dev@127.0.0.1" --admin_password="admin"

When I vagrant ssh into the virtual machine and try to run the command to add a user as a super admin I get this error:

vagrant@vvv:/srv/www/cdc-wordpress$ wp super-admin add admin
PHP Warning:  in_array() expects parameter 2 to be array, string given in phar:///usr/local/bin/wp/vendor/wp-cli/super-admin-command/src/Super_Admin_Command.php on line 107
Warning: in_array() expects parameter 2 to be array, string given in phar:///usr/local/bin/wp/vendor/wp-cli/super-admin-command/src/Super_Admin_Command.php on line 107
Success: Super admins remain unchanged.

Here is my wp --info w/ version

vagrant@vvv:/srv/www/cdc-wordpress$ wp --info
PHP binary:	/usr/bin/php7.0
PHP version:	7.0.21-1~ubuntu14.04.1+deb.sury.org+1
php.ini used:	/etc/php/7.0/cli/php.ini
WP-CLI root dir:	phar://wp-cli.phar
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/srv/www/cdc-wordpress
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	/srv/www/cdc-wordpress/wp-cli.local.yml
WP-CLI version:	1.3.0-alpha-73062dd

Here it shows the users, and their privileges:

vagrant@vvv:/srv/www/cdc-wordpress$ wp user list
+----+------------+--------------+---------------+---------------------+---------------+
| ID | user_login | display_name | user_email    | user_registered     | roles         |
+----+------------+--------------+---------------+---------------------+---------------+
| 1  | admin      | admin        | dev@127.0.0.1 | 2017-07-26 14:44:11 | administrator |
+----+------------+--------------+---------------+---------------------+---------------+

Here is line 107 in Super_Admin_Command.php

if ( in_array( $user_login, $super_admins ) ) {

Please let me know if this is a fix you can provide, or if I need to change something in my env, or if this is something wrong with the new version of vvv(2.0).

Thanks for your time,

  • Jim
@jimboobrien
Copy link
Author

I see in the latest vvv-2.0 it is grabbing the nightly build, I already tried changing the version to --stable 1.2 and still got same result.

@danielbachhuber
Copy link
Member

Hi @jimboobrien,

Thanks for the report.

Just to make sure admin wasn't already added, can you share the output from wp super-admin list? Also, can you try the same process with a new user?

@danielbachhuber
Copy link
Member

Also, if you use triple backticks ```, it formats preformatted text in a much nicer manner. I've edited your comment correspondingly.

@jimboobrien
Copy link
Author

jimboobrien commented Jul 26, 2017

Thank you for the tip. Here is the output when I run the command wp super-admin list:

PHP Warning:  Invalid argument supplied for foreach() in /home/vagrant/.wp-cli/packages/vendor/wp-cli/super-admin-command/src/Super_Admin_Command.php on line 64
Warning: Invalid argument supplied for foreach() in /home/vagrant/.wp-cli/packages/vendor/wp-cli/super-admin-command/src/Super_Admin_Command.php on line 64

@jimboobrien
Copy link
Author

So I have found that when I vagrant up there are two entries in the database for site_admins in the sitemeta table. Once the empty key has been removed the wp super-admin list command and the add command work as expected. Therefore, might need to check on the wp multisite-install does not create a new site_admins key and instead updates the existing key.

Hope this helps.

  • Jim

@danielbachhuber
Copy link
Member

Hi @jimboobrien,

I wrote some test cases around this scenario in #8 and wasn't able to reproduce against a stock WordPress install. It seems like this behavior may be specific to your environment — somehow an invalid entry ended up in the first site_admins key. I'd suggest deleting both to clean that up.

If you can track down steps to reproduce the issue in a fresh WordPress install, I'd be happy to look at this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants