The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Login Redirect Help (2 posts)

  1. driz
    Posted 6 years ago #

    I'm using the following code to create a login link that will redirect the user to the previous page:

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

    The problem is that get_permalink() as described here: http://codex.wordpress.org/Template_Tags/get_permalink will return the URL of the last post in The Loop, not the permalink for the current page when used on archive pages or index pages. How can I get around this? As it is currently redirecting my users to incorrect pages.


  2. driz
    Posted 6 years ago #

    I found this: esc_url( wp_login_url( $_SERVER['REQUEST_URI'] ) ) but is this the best solution? and will it work with plugins etc that interact with the usual wp_login_url() function?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.