Created
March 10, 2014 19:44
-
-
Save strangerstudios/9472769 to your computer and use it in GitHub Desktop.
Assign Paid Memberships Pro level when roles change.
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) | |
{ | |
//we found a role related to pmpro level | |
if($role == "subscriber") | |
{ | |
pmpro_changeMembershipLevel(1, $user_id); | |
} | |
elseif($role == "administrator") | |
{ | |
pmpro_changeMembershipLevel(2, $user_id); //setup level 2 as an all access role or just give them level 1 | |
} | |
else | |
{ | |
//default to no level | |
pmpro_changeMembershipLevel(0, $user_id); | |
} | |
} | |
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