I do not want to show any pages to a registered student. I only want that a student only can access his dashboard only. So
1. How can I redirect all front-end pages like home, product, all courses to student dashboard when he is loged -in?
2. If user not loged-in I want to redirect all pages to a custom login page so how to do that?
I am assuming that when you say pages, you mean WP Admin - Pages.
Following code will do this :
https://gist.github.com/MrVibe/59d1a3dc3cef94f3907c
Let me know if this helped !
It worked. But i do not want to go on profile page. I want to redirect on student dashboard home where URL will be like "members/demo/dashboard/".
You can try out this code for that :
add_action('template_redirect','wplms_hide_general_pages_for_students',10);
function wplms_hide_general_pages_for_students(){
if(is_user_logged_in() && is_page() && !current_user_can('edit_posts')){
$user_id=get_current_user_id();
bp_core_redirect( apply_filters ( 'wplms_registeration_redirect_url', bp_core_get_user_domain( $user_id ).WPLMS_DASHBOARD_SLUG , $user_id ));
exit;
}
}
Thanks Its working great now.