I'm trying to build a code where non-members get redirected to the landing page. Unfortunately, the code that I've built works partly and results in a redirect loop.
if(is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel()) {
global $current_user;
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
echo 'Membership Level: ' . $current_user->membership_level->name;
} else {
wp_redirect(/my-account/orders/);
exit;
}
Any help would be appreciated. The first part of the if statement is working fine but the second half is returning redirect loop.
Thanks and Regards,
Piyush