• Resolved zewa

    (@zewa)


    Hi, thanks for this plugin, it is exactly what I searched for, just one question – is it possible to redirect a user to a previus url after registration?.. I have a closed woocommerce store, and we send the link to a product to a customer via email, so customer need to login to proceed, since all products are invisible for guests. So once customer make a login (its a UsersWP – Front-end login form, not a woocommerce login, if its matter), it should be redirected back to a previus link, now it redirected to a home page. Since the URL is changing and I can’t put it as a static page, I was wondering if there is some solution?

    Example of the whole process:

    send a link to customer vi amail — https://clinicatelematica.it/prodotto/visita-angiologica/

    customer click on link and get a login form

    after login is done customer gets redirected to https://clinicatelematica.it/prodotto/visita-angiologica/

    Hope I made it clear

    Thank you

    • This topic was modified 1 year, 8 months ago by zewa.
    • This topic was modified 1 year, 8 months ago by zewa.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ramon Ahnert

    (@rahmohn)

    Hi @zewa

    Yes. You can pass the previous link as a query argument in the URL by using the filters wflu_redirect_page_url and wflu_redirect_after_login_page_url. Example:

    add_filter(
    	'wflu_redirect_page_url',
    	function( $redirect_page ) {
    		$link = get_permalink();
    
    		$redirect_page = add_query_arg(
    			array(
    				'redirect-to' => $link,
    			),
    			$redirect_page
    		);
    
    		return $redirect_page;
    	},
    	10
    );
    
    add_filter(
    	'wflu_redirect_after_login_page_url',
    	function( $redirect_to ) {
    		if ( empty( $_GET['redirect-to'] ) ) {
    			return $redirect_to;
    		}
    
    		$redirect_to_arg = esc_url( wp_unslash( $_GET['redirect-to'] ) );
    
    		if ( empty( $redirect_to_arg ) ) {
    			return $redirect_to;
    		}
    
    		$redirect_to = $redirect_to_arg;
    
    		return $redirect_to;
    	},
    	10
    );
    Thread Starter zewa

    (@zewa)

    Thank you for a fast responce, it works if I use as acount page one of Woocommerce and it doesnt work unfortunately with account page of UsersWP – Front-end login form, which I use, but I suppose I can switch to woocommerce account login page. I guess there is some kind of conflict with Users WP

    Plugin Author Ramon Ahnert

    (@rahmohn)

    I think it’s because the default WP login page uses the parameter redirect_to (note that I use redirect-to in the code snippet above) to redirect and remove other arguments in the URL.

    Maybe you can try to use redirect_to to perform the redirect.

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