change home page post login

Home Forums Legacy Support Support queries Other issues change home page post login

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #222262
    ajacks
    Participant
    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
    #222263
    ajacks
    Participant
    This reply has been marked as private.
    #222344
    Mk
    Moderator
    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);
    #222346
    ajacks
    Participant
    This reply has been marked as private.
    #222368
    Mk
    Moderator
    For site lock set it in the following manner:  
    #222389
    ajacks
    Participant
    This reply has been marked as private.
    #222528
    Mk
    Moderator
    Please check now I changed login redirect option to the home page in wp-admin->LMS-> Settings.
    #222530
    ajacks
    Participant
    This reply has been marked as private.
    #222621
    Mk
    Moderator
    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.
    #222655
    ajacks
    Participant
    hey its cool, although i added the code and the platform stopped loading... "site is experiencing technical difficulties..." what do you suggest I do?
    #222711
    Anshuman Sahu
    Keymaster
    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);
    #222809
    ajacks
    Participant
    thanks Alex, this worked well! please close this topic.
    #222868
    Mk
    Moderator
    Great, Thanks for the confirmation. I am closing this topic.
Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘change home page post login’ is closed to new replies.