WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_login_url redirection from a 404 page (2 posts)

  1. Hamburger
    Member
    Posted 3 years ago #

    Hi there, I currently have this code which turns into a link.

    <a href="<?php echo wp_login_url( get_permalink() ); ?>">Administrator Login</a>

    When this link is clicked, the user gets redirected to the standard login page, once credentials are done the user is redirected BACK to the original page they came from. This is quite excellent!

    Now when I send someone a link to a draft and they are not logged in, they are greeted with a 404 page. Perfectly understandable.

    However, If they use that same link I was talking about earlier to login, the redirection gets lost somehow and the user is taken to the Dashboard instead of the draft post.

    Is there anyway that a 404 page can keep the referrer when using wp_login_url?

  2. Hamburger
    Member
    Posted 3 years ago #

    <a href="<?php echo esc_url( wp_logout_url( $_SERVER['REQUEST_URI'] ) ); ?>">Log out</a>
    
    <a href="<?php echo esc_url( wp_login_url( $_SERVER['REQUEST_URI'] ) ); ?>">Log out</a>

    Happneed because i was doing this outside the loop. Where is everyone by the way? Support is a ghost town in here

Topic Closed

This topic has been closed to new replies.

About this Topic