Last active
August 29, 2015 14:16
-
-
Save labsecrets/a773c0de6c6a612318c2 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Set Default WP Role to Membership Levels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function assign_pmpro_level_to_role($user_id, $role, $old_roles) | |
{ | |
global $current_user; | |
//checks if the user doesn't have a membership level yet | |
if(!$current_user->ID) { | |
//we found a role related to pmpro level | |
if($role == "customer") | |
{ | |
pmpro_changeMembershipLevel(20, $user_id); //gives default customers the level 20 free registration membership | |
} | |
elseif($role == "administrator") | |
{ | |
pmpro_changeMembershipLevel(10, $user_id); //gives admin role registrants the all access level 10 membership | |
} | |
} | |
} | |
add_action('set_user_role', 'assign_pmpro_level_to_role', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment