Forked from strangerstudios/assign_pmpro_level_to_role.php
Created
February 19, 2014 10:48
-
-
Save cyberwani/9089704 to your computer and use it in GitHub Desktop.
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 == "pmpro_level_1") | |
{ | |
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