Skip to content

WordPress user roles and capabilities — beyond the defaults

WordPress ships five user roles that fit a blog and break for everything else. How to extend roles and capabilities cleanly without painting yourself into a corner.

WordPress ships with Subscriber, Contributor, Author, Editor, Administrator — five roles that fit a 2007-era blog and break the moment a real organization needs to model “this person manages WooCommerce orders but can’t touch posts” or “this freelancer can edit drafts in one category and nothing else.” The fix is not “give everyone Editor and hope” — it is understanding the capability model and extending it where the defaults stop.

What’s happening

A WordPress role is a named bundle of capabilities. A capability is a single permission like edit_posts, manage_options, upload_files. The wp_user_roles option stores the mapping; WP_User checks capabilities through user_can( $cap ). Plugins add their own capabilities (manage_woocommerce, wpcf7_edit_contact_forms), and the result on a mature site is 50-200 capabilities a user might or might not have.

The defaults break in three common ways: (1) Editor is too powerful (can edit other users’ posts in every post type); (2) Contributor is too weak (can’t upload images, breaking any post with media); (3) there is no role for “shop manager who can refund orders but not change site settings.” Plugins like WooCommerce ship their own roles to fill the gap, which works for that plugin but doesn’t compose cleanly across plugins.

How to verify

wp role list
wp cap list editor
wp user list --role=editor --fields=user_login,user_email

wp eval 'print_r( wp_roles()->roles );' | head -50
wp eval 'print_r( wp_roles()->roles["custom_role"] );'
wp user list-caps 5

Audit who has manage_options (full admin): wp user list --capability=manage_options --fields=user_login. On most sites the list should be 1-3 people. Anything above 5 is a finding worth raising.

The fix

  1. Use a role editor plugin, but treat it as a write tool, not a UI. Members or User Role Editor let you build custom roles, export them as code, and check them into the theme. The plugin UI is for prototyping; the resulting role definitions belong in functions.php or an mu-plugin.
  2. Define roles in code, not in the database. Roles stored only in wp_options don’t replicate to staging. Use add_role() in a plugin activation hook (or an mu-plugin’s init action) so the role definition is version-controlled.
  3. Build roles from least privilege upward. Start with Subscriber capabilities, add only what the user needs. The instinct to clone Editor and remove capabilities leaves dangerous defaults in place.
  4. Add granular post-type capabilities. A custom post type registered with capability_type => 'product' creates edit_products, delete_products, etc. Map them onto specific roles instead of using the generic edit_posts.
  5. Audit on a schedule. Run wp user list --capability=manage_options quarterly. People change roles in the organization; their WordPress capabilities rarely follow. The enterprise WordPress support operating model includes quarterly access reviews as part of the standard SLA.

When the role model is fighting the editorial workflow and people are either over-privileged or constantly blocked, Stack Harbor’s enterprise WordPress support team rebuilds the role matrix from least-privilege upward — start the conversation for a role redesign pass.