Viewing 3 replies - 1 through 3 (of 3 total)
  • Adrian

    (@adrianfraguela)

    You can use the wp_login_form() function like this

    <?php
        args = 'redirect' => site_url( $_SERVER['REQUEST_URI'] ); //sends them back to the page that the form was on
        wp_login_form($args);
    ?>
    Thread Starter Mike

    (@mikebboyledesigncom)

    Thanks, where would I put this piece of code?

    Adrian

    (@adrianfraguela)

    This code would generate a login form wherever you put it. So for your private page I would use the is_user_logged_in() function like this:

    <?php
    if ( is_user_logged_in() ) {
        //show the page content you want them to see
    } else {
        args = 'redirect' => site_url( $_SERVER['REQUEST_URI'] ); //sends them back to the page that the form was on
        wp_login_form($args);
    }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect user to intended URL after login on private site’ is closed to new replies.