The Roles for Membership Add On adds a custom WordPress Role for each PMPro Membership Level.
With this plugin enabled, your membership levels now include a setting to assign one or more role to members after signup.
- Define custom roles for your membership levels, each with specific capabilities and permissions.
- Assign multiple WordPress core roles to members.
- Upgrade members to higher core roles like ‘Author’ for enhanced site contribution.
- Integrate Paid Memberships Pro with other plugins that handle user access based on WordPress role.
How it Works
This plugin allows you to manage and assign custom roles to your WordPress users as part of their membership. You can use this Add On to assign a level-specific custom role or to adjust the core WordPress role a member receives after signup.
Activating the plugin will create a new custom role for each membership level.
- Custom roles will use the membership level’s name as the
display_name
. - The
role
value for a custom role looks like this:pmpro_role_x
. Wherex
is the membership level’s ID. - Custom roles have the same basic capabilities as the core WordPress
subscriber
role. You can adjust the custom role capabilities using the method outlined below.
Video Demo: How to Assign a Custom Role to WordPress Users
Installation
You must have the Paid Memberships Pro plugin installed and activated to use this Add On.
- Navigate to Memberships > Add Ons in the WordPress admin.
- Locate the Add On and click “Install Now“.
- Or, to install this plugin manually, download the .zip file above.
- Upload the compressed directory (.zip) via the Plugins > Add New > Upload Plugin screen in the WordPress admin.
- Activate the plugin through the Plugins screen in the WordPress admin.
Settings
- Navigate to Memberships > Settings > Memberships Levels in the WordPress admin.
- Select a Membership Level to edit.
- Locate the Role Settings fields in the Other Settings section.
- To adjust the role for members of this level, choose one or more roles from the list of Roles.
- Save settings.
Assigning Custom Roles for New and Existing Members
Membership settings will define and assign the custom role(s) to new members joining your site.
Cancellation or removal of a user’s membership will result in the removal of custom roles assigned for their previous level, with the site default role being assigned. You can adjust your site default role under Settings > General in the WordPress admin.
Custom Role Capabilities
When custom roles are created for each level, they inherit the same capabilities as the WordPress subscriber
role.
This means members can log in to your WordPress site, reset their password, update their profile, and, of course, view content.
Some sites need to give members a different level of access to WordPress features, like the right to create a post, or for features of other plugins, like forum moderation in BuddyPress or bbPress.
- You can adjust the custom role capabilities using the
pmpro_roles_default_caps
filter. - Or, you can also use a plugin like User Role Editor to add or remove custom capabilities via a settings page in the WordPress dashboard. Below is a screenshot of editing a custom role created with this Add On within the User Role Editor settings page.
For more information on WordPress Roles and Capabilities, see this article from WordPress.org.
How to Safely Remove the Roles for Membership Add On
If you no longer want to use this plugin, click the Delete Roles and Deactivate link in the plugin’s action links. Navigate to Plugins > All screen in the WordPress dashboard.
Here’s what happens when you trigger this process:
- All users and members with a custom membership role will have their role set back to the WordPress “subscriber” default.
- Users with a default WordPress role will remain unchanged.
- The WordPress site’s database will undergo cleanup, removing the custom roles.
Screenshots
Action and Filter Hooks
The following actions and filters are available in this Add On:
do_action( 'pmpro_roles_delete_membership_level', $delete_id );
Triggers a custom function when a membership level is deleted, passing the ID of the deleted level as a parameter.
do_action( 'pmpro_roles_after_role_change', $user, $old_user_levels, $old_roles, $new_roles );
Runs after a user’s role has changed, providing access to the user object, their previous levels, old roles, and new roles for additional processing or logic.
apply_filters( 'pmpro_roles_downgraded_role', get_option( 'default_role' ) );
Modify the default role assigned to a user when their membership is downgraded, using the current default role setting as the starting point.
apply_filters( 'pmpro_roles_exclude_other_pmpro_roles', true, $level_id );
Control whether to exclude other PMPro custom roles when assigning a new role to a user at a particular membership level.
apply_filters( 'pmpro_roles_hide_admin_role', true, $edit_level );
Determines whether the administrator role should be hidden from the roles list in the membership level settings, which can be useful for preventing accidental assignment of admin privileges.
apply_filters( 'pmpro_roles_default_caps', $capabilities );
Modify the default capabilities array assigned to the custom roles created for each membership level, allowing for custom permissions to be set as needed.
Note: This plugin is based on the original PMPro Roles plugin by Josh Levinson that was developed in 2013.
This is a Free Add On.
Create a free account or log in to gain access to downloads and documentation.