Restrict Users To Access the Home Page

This tip will work when someone do not want to show the Home Page of his site. Whenever a user try to access the Home Page he will land on his dashboard.

Paste the below code in wp-admin > Plugins > Editor > Select WPLMS Customizer Plugin > wplms-customizer.php

add_action('template_redirect','redirect_user_to_dashboard');

function redirect_user_to_dashboard(){

if(is_front_page() && is_user_logged_in()){

global $current_user;

$user_id = get_current_user_id();

$login_page=bp_core_get_user_domain($user_id).'/dashboard/';

wp_redirect($login_page);

exit;

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *