Hi,
I would like to use my home page as a Site Lock page - so just like on the site lock template - the users should not be able to access the home page when logged in... if I apply site lock page template then I loose the look and feel of the home page and the default login appears... also how do i control where the users are redirected to...
please guide
thanks
This reply has been marked as private.
MkModerator
Add this code in your customizer and set redirect URL in given code.
add_filter('login_redirect',function ($redirect_url,$request_url,$user){
$redirect_url = '<b>https://wplms.io</b>'//REPLACE wplms.io URL AND SET REDIRECT URL HERE IN SINGLE QUOTE;
return $redirect_url;
},9999,3);
This reply has been marked as private.
MkModerator
For site lock set it in the following manner:
This reply has been marked as private.
MkModerator
Please check now I changed login redirect option to the home page in wp-admin->LMS-> Settings.
This reply has been marked as private.
MkModerator
Sorry for all the false replies above.
I think you want home page accessible for non logged-in users only.
Add this code in your customizer
NOTE: Remember to replace text CUSTOM_URL with your predefined url or share the URL.
add_action('template_redirect',function (){
if(is_home() ) {
if(is_user_logged_in())
wp_redirect('CUSTOM_URL');
}
});
Please remove older codes and settings too.
hey its cool, although i added the code and the platform stopped loading...
"site is experiencing technical difficulties..."
what do you suggest I do?
Sorry there is a little mistake in code the correct code is :
add_action('template_redirect',function (){
if(is_home() || is_front_page()) {
if(is_user_logged_in()){
wp_redirect('http://localhost/wplms/about/');
exit();
}
}
},1);
thanks Alex, this worked well! please close this topic.
MkModerator
Great,
Thanks for the confirmation. I am closing this topic.