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

2.4.0: wp user remove-role <id> with no role arguments could produce a less scary display result #291

Open
lkraav opened this issue Apr 20, 2020 · 3 comments

Comments

@lkraav
Copy link

lkraav commented Apr 20, 2020

Bug Report

Describe the current, buggy behavior

wp user set-role with no [role] argument is documented as "adds the default role".

But matching remove-role synopsis is undocumented and also produces a scary display result:

[cxl ~/www]# wp user remove-role 293
Success: Removed leho (293) from <site>.

This looks like my user just got wiped. Fortunately it's not the case, as wp user get confirmed.

Describe how other contributors can replicate this bug

See commands above.

Describe what you would expect as the correct outcome

a) user remove-role should not proceed without a [role] parameter
b) match set-role strategy and remove default role + add documentation

Let us know what environment you are running this on

# wp cli info
OS:     Linux 2.6.32-754.17.1.el6.x86_64 #1 SMP Tue Jul 2 12:42:48 UTC 2019 x86_64
Shell:  /bin/bash
PHP binary:     /opt/cpanel/ea-php73/root/usr/bin/php
PHP version:    7.3.16
php.ini used:   /opt/cpanel/ea-php73/root/etc/php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/convers/public_html
WP-CLI packages dir:    /home/convers/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
@lkraav
Copy link
Author

lkraav commented Apr 20, 2020

PS looking at user set-role output, I'm not sure it fully makes sense either:

# wp user set-role 293 administrator
Success: Added leho (293) to <site> as administrator.

This reads like a user object was created, instead of a role change.

Your thoughts?

@elenachavdarova
Copy link

Hi, actually when there is no role listed, the user is being "deactivated" meanting they will no longer have access to the backend of the site, but their posts will still be visible at the website.

This is actually a good option to have in wp-cli on my opinion. Maybe the message can be edited only as it is a bit missleading.

@danielbachhuber
Copy link
Member

From the code, it looks like the user is meant to be removed from the site if no role is specified:

// Multisite
if ( function_exists( 'remove_user_from_blog' ) ) {
remove_user_from_blog( $user->ID, get_current_blog_id() );
} else {
$user->remove_all_caps();
}
WP_CLI::success( "Removed {$user->user_login} ({$user->ID}) from " . site_url() . '.' );

When I tested, it seems like the role is removed as expected:

$ wp user remove-role danieltesting
Success: Removed danieltesting (2) from https://vanilla.test.
$ wp user list
+----+---------------+---------------+-----------------------------+---------------------+---------------+
| ID | user_login    | display_name  | user_email                  | user_registered     | roles         |
+----+---------------+---------------+-----------------------------+---------------------+---------------+
| 1  | daniel        | daniel        | [email protected]         | 2023-05-17 12:02:14 | administrator |
| 2  | danieltesting | danieltesting | [email protected] | 2023-07-13 16:16:05 |               |
+----+---------------+---------------+-----------------------------+---------------------+---------------+

Maybe we could improve the documentation?

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

3 participants