Core Paid Memberships Pro assigns the site default role (most often “subscriber”) to all new users created during membership checkout. We also offer the optional Roles for Membership Add On for sites that need to customize the WordPress role that gets assigned by membership level.
Using this Add On, you can specify what role the member should receive in addition to their membership level: a custom-generated role for their level, a default WordPress role, or any combination of roles that you need.
By default, all custom-generated roles match the capabilities of the WordPress “subscriber” role.
For some sites, like Associations or multi-author blogs, you may want your members to have additional WordPress capabilities for their level and user role.
This code recipe will allow you to change the default capabilities of custom-generated roles when using Paid Memberships Pro and the Role for Membership Add On.
About the Code Recipe
When this code recipe is run on the site, it will perform a one-time edit of the user capabilities for the generated level roles.
In this example, the code gives all users with the pmpro_level_1
role the capability to create and edit their own posts.
Before using this code recipe, we recommend understanding the difference between roles and levels for membership sites.
If you prefer a no-code approach, consider using the User Role Editor plugin. This plugin gives you the flexibility to manage custom roles and capabilities through an intuitive user interface. You can also use this tool to create your custom capabilities for built-in roles.
The Code Recipe (PHP)
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
Update lines 28 to 31 to change what the role to be updated and what capabilities you would like to add or adjust.
Once the code is in place, navigate to your WordPress admin and append the URL parameter ?pmpro_update_role_caps=1
. Once the script is run, you can remove the snippet from your site. The capability update is permanently stored in your WordPress site database.
Free Course: Membership Site Development—The Basics
Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.