/*
Login redirect example using PMPro to check membership levels.
*/
function my_login_redirect($redirect_to, $request, $user)
{
//is there a user to check?
if(!empty($user->ID))
{
//check level
if(pmpro_hasMembershipLevel(1, $user->ID))
return home_url("/level-one/");
elseif(pmpro_hasMembershipLevel(2, $user->ID))
return home_url("/level-two/");
elseif(pmpro_hasMembershipLevel(3, $user->ID))
return home_url("/level-three/");
else
return home_url();
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);