• Resolved sunnyschafieh

    (@sunnyschafieh)


    Hi,how do you redirect after login as well? I want users to be redirected to the same url after login and registration.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support sanjuacharya77

    (@sanjuacharya77)

    Hi @sunnyschafieh,

    You can do that using a piece of code. Please paste the following code in your active theme’s functions.php file at the end and it will do the trick.

    add_action( 'user_registration_before_registration_form', 'ur_set_register_redirect_url' );
    function ur_set_register_redirect_url( $form_id ) {
    	if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
    		set_transient( 'originalLoginRefererURL', $_SERVER['HTTP_REFERER'], 60 * 60 * 24 );
    	}
    }
    add_filter( 'user_registration_redirect_from_registration_page', 'ur_register_redirect_back', 10, 2 );
    function ur_register_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 helps or not and I will get back to you.
    Regards!

    Thread Starter sunnyschafieh

    (@sunnyschafieh)

    Thanks

    Plugin Support sanjuacharya77

    (@sanjuacharya77)

    Hi @sunnyschafieh,

    You are welcome. Have a great day ahead ??

    Regards!

    Thread Starter sunnyschafieh

    (@sunnyschafieh)

    Hi , I pasted this code but it does not redirect after login.

    Thanks

    Thread Starter sunnyschafieh

    (@sunnyschafieh)

    also is there a logout shortcode?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect’ is closed to new replies.