Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] I want to redirect all the logged out users to login page


  • anivarth
    Participant

    @anivarth

    Simply to say I want all the logged out users to the login page and new people also to login page.
    Please suggest me with a plugin

    And one more thing I want to change the size of the text at the registration which says:

    Registering for this site is easy. Just fill in the fields below, and we’ll get a new account set up for you in no time.
    -to-:
    **Some other text here**

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

  • Henry Wright
    Moderator

    @henrywright

    Regarding the redirect, I’m not sure if there is a plugin but you can add this to your theme’s functions.php file:

    function my_redirecter() {
        if ( ! is_user_logged_in() ) {
            wp_redirect( home_url() . '/login/' );
            exit();
        }
    }
    add_action( 'init', 'my_redirecter' );

    anivarth
    Participant

    @anivarth

    Thank you @henrywright for the answer


    anivarth
    Participant

    @anivarth

    @henrywright I forgot to ask you that if a user want to register then what is the situation.
    I mean that only there should be the register page available for the user who are not logged in.


    Henry Wright
    Moderator

    @henrywright

    You can check that with bp_is_register_page(). Thinking about it, you’ll need logged out users to also have access to the activation page so that they can activate their account. You can use bp_is_activation_page() for that. So, the function becomes:

    function my_redirecter() {
        if ( ! is_user_logged_in() && ! bp_is_register_page() && ! bp_is_activation_page() ) {
            wp_redirect( home_url() . '/login/' );
            exit();
        }
    }
    add_action( 'init', 'my_redirecter' );

    anivarth
    Participant

    @anivarth

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] I want to redirect all the logged out users to login page’ is closed to new replies.
Skip to toolbar