I have a situation where I need users to be flagged as "Instructors" on a site. That role should basically be whatever the user's current role is with the added capability to see comments from students on a custom post type called "Questions".

I'm struggling with how to implement this conceptually. Should I just add a new capability and have it assigned by itself, or should I add it and assign it to a new role as well?

[edit]From kaiser's resources, it appears I should just add the custom capability and assign it to users on an individual basis, perhaps from my own plugin's options/settings admin page, as opposed to creating a specific role[/edit]

What happens if I change the user's role to something else (say from Admin to Editor) but still want them to have that capability? Is this a fairly easy thing to program in a custom plugin (which is where I'm doing all of this from), or is this going to be a monumental undertaking?

The following are my main questions;

  1. What is the underlying logic when switching user roles from one to another?

  2. Do custom capabilities that were assigned carry over when switching user roles, or does the new role assignment overwrite anything else?

  • 1
    Please read into map meta capabilities (related on topic post). And into Users and Roles in general.
    – kaiser
    Commented Feb 24, 2014 at 18:26
  • Thanks for the resources kaiser. One question that still remains after looking at those, for me, is if I add a capability and assign it to a user, if I change their role from one of the system-defined ones to another does it overwrite that additional custom capability, or just the set of system-defined ones?
    – John
    Commented Feb 24, 2014 at 18:52
  • John, please first update your question (file an edit) with your newly gained knowledge :)
    – kaiser
    Commented Feb 24, 2014 at 18:56

1 Answer 1


WordPress capability system roughly works like the following:

  • Capabilities can be attached to users or roles
  • Roles can be attached to users
  • Roles are a flat system, so there is nothing overruling something else
  • Role names are capabilities as well

Keep in mind that role names are capabilities as well, but you shouldn't check against them. The same goes for the deprecated level-0 until level-9 caps.

In theory WordPress supports multiple roles per user - something that is extremely convenient as you can add and remove Capability packages summed under role names. It just has no UI and isn't built in. Oh, and there's (afaik) no plugin that delivers that.

So: yes assigning capabilities users is OK. But keep in mind that this can quickly can get a maintenance nightmare. In most cases it's better (not perfect) to just grab a role, copy its capabilities over to your new role and add the new role to a user. When you then want to change something, just exchange to role for all users that need to have a new set of caps.

Note: This is my opinion. Others might have a different one when it comes to what is a nightmare and what not :)

  • Thanks kaiser, this helps immensely. I know that the "User Role Editor" plugin allows assigning multiple roles. I may end up using that plugin in the end, but don't really like the idea of having a custom plugin with some core functionality that is dependent on another third-party plugin, so I want to explore how much work it might take to just bake it in to my own. Knowing that role names are essentially capabilities helps immensely. Thanks.
    – John
    Commented Feb 24, 2014 at 20:34
  • @John Role names are capabilities as well. But they're also saved in the database and summon the capabilities.
    – kaiser
    Commented Feb 24, 2014 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.