Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created March 10, 2014 19:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strangerstudios/9472769 to your computer and use it in GitHub Desktop.
Save strangerstudios/9472769 to your computer and use it in GitHub Desktop.
Assign Paid Memberships Pro level when roles change.
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