Skip to content

wp role create --clone grants capabilities that the source role denies #88

Open

Description

@dhrupo

wp role create <role-key> <role-name> --clone=<role> copies every capability of the source role as granted, including the ones the source role explicitly denies:

$ wp cap add author spectate --grant=false
$ wp role create reporter Reporter --clone=author
$ wp cap list reporter --show-grant
upload_files,true
edit_posts,true
edit_published_posts,true
publish_posts,true
read,true
level_2,true
level_1,true
level_0,true
delete_posts,true
delete_published_posts,true
spectate,true

Role_Command::create() takes only array_keys( $role_obj->capabilities ) and then calls add_cap( $cap ) for each one. add_cap() defaults $grant to true, so the grant value of the source role is lost.

Expected: the clone has the same capabilities with the same grant values, so spectate,false.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions