This topic has 3 replies, 2 voices, and was last updated 8 years by Laura.

  • Author
  • #127814
     ahmadfaiz11
    Participant

    I want to redirect a non logged in user to the registration page when trying to access any profile.

    How to do that?

    #127867
     Laura
    Moderator

    Try by adding this to functions.php of child theme

    COPY CODE
    
    add_action( 'template_redirect', 'redirect_to_specific_page' );
    
    function redirect_to_specific_page() {
    
    if ( is_page('slug') && ! is_user_logged_in() ) {
    
    wp_redirect( 'http://www.example.dev/your-page/', 301 ); 
      exit;
        }
    }
    

    Change the url with your registration page

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #127913
     ahmadfaiz11
    Participant

    not working

    #128144
     Laura
    Moderator

    Hello, then try the plugin peter’s login redirect 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?