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

wp cap list output does not reflect grant #18

Closed
kshaner opened this Issue Mar 7, 2018 · 4 comments

Comments

3 participants
@kshaner
Contributor

kshaner commented Mar 7, 2018

Listing a role's capabilities does not show whether the capability has been granted or not.

Example code from a plugin/theme:

get_role('contributor')->add_cap('custom_capability', false)

wp cli output for wp cap list contributor:

edit_posts
read
level_1
level_0
delete_posts
custom_capability

Whether the adding of false for a capability is correct instead of removing it is another discussion, but the grant status should be shown in the output since it is a valid argument for add_cap.

I would propose the output using the table formatter by default and adding a second column for grant.

@dougaxe1

This comment has been minimized.

dougaxe1 commented Mar 7, 2018

+1 for addressing this issue. I don't feel like this command is useful without the distinction.

In the docs, wp cap list is described as:

Lists capabilities for a given role.

To me, that means capabilities a given role is granted. As an alternative to showing grant in a different column, I propose hiding all capabilities with grant = false since user_can( $user, $cap ) === false

@schlessera

This comment has been minimized.

Member

schlessera commented Mar 8, 2018

Yes, I agree, this distinction is important and mustn't get lost.

To keep from breaking existing scripts, I think we should go with @dougaxe1 's proposal. Additionally, we can provide a more detailed list representation under a separate flag, like --show-grants or so.

@schlessera

This comment has been minimized.

Member

schlessera commented Apr 19, 2018

Fixed via #19

@schlessera schlessera closed this Apr 19, 2018

@schlessera schlessera added this to the 1.0.6 milestone Apr 19, 2018

@schlessera

This comment has been minimized.

Member

schlessera commented Apr 19, 2018

Thanks for taking care of this, @kshaner ! 🙂

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