I have found a way already using the Paid Membership Pro and the tweak given here. Just assigned the page to be accessible by the member only.
Hi,
I would like to ask how can I stop non-logged in user in accessing the cart and check out page?
I don't know the equivalent of the code add_action('bp_before_directory_course_page',array($this,'redirect_if_not_loggedin')); if i will use it in the cart and checkout page. Should I use 'bp_before_cart_page' ?
I have used the command below in stopping non logged in user to access the course page and it worked
add_action('bp_before_directory_course_page',array($this,'redirect_if_not_loggedin'));
function redirect_if_not_loggedin(){
if(!is_user_logged_in()){
$location = get_site_url(); // Change this location to a static url where you want to redirect the user to.
echo '<script type="text/javascript">
<!--
window.location= "'. $location .'";
//-->
</script>';
exit();
}
}
Thanks!