• Resolved levelUphop

    (@leveluphop)


    Hi, would it be possible for the plugin to redirect users to the link they originally clicked on? An issue right now is that regardless of what link you click on, you’re always redirected to the same default page

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am so desparate for this feature……

    Hi @evangelismcoach, @leveluphop,

    If you want your users to redirect to the same page they clicked on then you need to paste the provided code in your active theme’s functions.php file and it will do the trick.
    Here is the code:

    //Redirect back to the previous page after login**************
    add_action( 'user_registration_before_customer_login_form', 'ur_set_redirect_url' );
    function ur_set_redirect_url() {
    if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
    set_transient( 'originalLoginRefererURL', $_SERVER['HTTP_REFERER'], 60 * 60 * 24 );
    }
    }
    add_filter( 'user_registration_login_redirect', 'ur_redirect_back', 10, 2 );
    function ur_redirect_back( $redirect, $user ) {
    if ( true === ( $redirect_url = get_transient( 'originalLoginRefererURL' ) ) ) {
    delete_transient( 'originalLoginRefererURL' );
    return $redirect_url;
    }
    return $redirect_url;
    }
    

    Let me know if it works for you not and I will get back to you.
    Regards!

    Thread Starter levelUphop

    (@leveluphop)

    Thank you very much, worked perfectly

    • This reply was modified 4 years, 5 months ago by levelUphop.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamic redirect’ is closed to new replies.