I am using WordPress Multisite with Paid Membership Pro for two types of member users (Corporate companies, individuals). I have subsites for the corporate users (ex. corporate.mysite.com) that has member access to content on mysite.com. I have setup different 'Dashboards' for individual tiers and corporate users. For instance a 'rookie' user is redirected to mysite.com/rookie-dashboard/ and a corporate user is redirected to corporate.mysite.com/dashboard/ after logged in. Each member is setup as a subscriber and is assigned a user level ID based on which package they purchased (via PaidMembershipPro)
That said, I'm trying to setup a function switch redirect if a user tries to access the wrong dashboard. Here is what I have setup so far:
function dashboard_redirect()
{
global $current_user, $post;
switch ($current_user->membership_level->id) {
case "2":
// Rookie Member level
wp_redirect('/rookie-dashboard/');
break;
case "3":
// Player Member level
wp_redirect('/player-dashboard/');
break;
case "4":
// All-Star Member level
wp_redirect('/allstar-dashboard/');
break;
case "5":
// Coach Member level
wp_redirect('/coach-dashboard/');
break;
case "6":
// Owner Member level
if (! is_page(197) ) {
return false;
} else {
wp_redirect('/dashboard/');
}
break;
case "7":
if (! is_page('/dashboard/') ) {
return false;
} else {
// Corporate
wp_redirect('http://corporate.mysite.com/dashboard/');
}
}
}
add_action('template_redirect', 'dashboard_redirect');
The issue that I am running into is nulling the process when the right user is on their dashboard page. I get infinite loops if I just have a switch casse with the redirects so I tried adding a if/then to the switch but can't seem to get it to work. Not sure what I'm doing wrong.