• brijeshk89

    (@brijeshk89)


    Hi,

    I am a plugin vendor and my user wants to allow users with a custom role to be able to access my plugin functionality.

    I created a custom capability from my plugin code manage_ip_ranges. Now the test user has 3 Roles Editor, Super Editor (Custom Role), Subscriber.

    Using your plugin if I allow the custom cap manage_ip_ranges to Super Editor (Custom Role) it works only if the user has 1 Role assigned “Super Editor (Custom Role)”. If the user has multiple roles it takes the cap based on the last role assigned.

    So even if I allowed the cap for Super Editor (Custom Role) and the same is not allowed to “Subscriber” due to this it takes the cap from the last role assigned and does not allow access to the intended functionality.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    WordPress sums capabilities from all roles granted and checks the full list of capabilities, not from the last granted role only. It uses function current_user_can( ) for this purpose.

    Re-check if something is wrong with your test.

    Thread Starter brijeshk89

    (@brijeshk89)

    Hi Vladimir,

    So if a capability is allowed in any one of the assigned Roles it should be accessible to the user right ?

    Then it looks like a bug, I created a new Role and assigned the custom capability. Then I created a user and assigned a few roles and the new custom role as well. If the custom role is not the last role assigned to the user in List Users page the custom capability is not enabled in current_user_can but if the custom role is the last role assigned to the User then the custom capability is enabled in current_user_can

    Can you try to replicate this on your side ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Capability Not Working when Multiple Roles Assigned’ is closed to new replies.