WordPress.org

Support

Support » How-To and Troubleshooting » Login Redirect Help

Login Redirect Help

  • 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.

    Thanks

Viewing 1 replies (of 1 total)
  • 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?

Viewing 1 replies (of 1 total)
  • The topic ‘Login Redirect Help’ is closed to new replies.