WordPress.org

Ready to get started?Download WordPress

Forums

Login Redirect Help (2 posts)

  1. driz
    Member
    Posted 3 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.

    Thanks

  2. driz
    Member
    Posted 3 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

Tags

No tags yet.