Created
February 18, 2014 16:11
-
-
Save strangerstudios/9073990 to your computer and use it in GitHub Desktop.
Assign a Paid Memberships Pro level based on user role when user roles are updated.
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); |
where to put this file?
This worked great, thanks so much! This works fine by putting it in your theme functions.php file --> wp-content/themes/your-theme-name/functions.php
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
David can I reach you via email somewhere? I have a more detailed question.
nye@nyetech.com