-
Notifications
You must be signed in to change notification settings - Fork 89
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
Updating a user with an invalid role should show a warning #160
Comments
Thanks for the report, @johnbillion. Some follow-up questions (thinking aloud, not necessarily for you):
|
Idea that addresses 1 and 2: Trigger a warning instead of erroring. |
Does core error when updating a user with an invalid role? |
This is an interesting but old thread, that addresses a question I had. And doesn't seem to be addressed elsewhere. Although there are validation checks in core creating a new user, e.g. for the email address, there do not appear to be checks on role. It is entirely valid for users to have no role, but there does not seem to be any restriction about having a role that's not in the database. Removing a role from the database does not seem to remove it from the users, so conversely, one might create users with a certain role, then later create the role to grant capabilities. Relevant code: User WP-User Roles |
@johnbillion Still think we should implement this? If so, I'm good with it. |
It is unusual (or not?) that WP core doesn't validate the role, but I think there's value in doing so in WP-CLI. +1 for accepting the role but triggering a warning, which means if you're creating a user interactively and you typo the role then at least you'll see a warning. |
Right now entering the invalid URL will give a warning than a success message and in the WordPress dashboard the role will be changed to none |
The following command always succeeds. Ideally it should fail when an invalid role name is passed.
wp user update <username> --role=bananas
The text was updated successfully, but these errors were encountered: