Here’s what I wanted to achieve:
I have buddypress installed and URI restricted to level 1 users. However, I want level 0 users to be able to access a similar, non buddypress page.
When a level 0 tries to access the buddypress page, they get redirected to the membership options page.
What I was hoping to do was query the URI and if they had tried to access the buddypress page, then redirect them from the MOP to the non buddypress equivalent.
This works by putting this shortcode in the MOP.
[s2Redirect if_page_is="a_buddypress_page" redirect_to="the_none_buddypress_page" /]
function mop_uri_redirect_shortcode($atts) {
$_g = stripslashes_deep ($_GET);
if (isset ($_g["_s2member_seeking"]["ruri"])){
$seeking_uri = esc_html (base64_decode ($_g["_s2member_seeking"]["ruri"]));
if (strpos($seeking_uri, $atts['if_page_is']) >0)
echo '<script type="text/javascript">window.location = "' . $atts['redirect_to'] . '"</script>';
}
}
add_shortcode('s2Redirect', 'mop_uri_redirect_shortcode');
This works but it’s a really dirty hack because it means the Membership Options Page has to load before it redirects.