• I am adding in code snippets the recipe (wp_bouncer_redirect_url) to redirect to a specific page when there are multiple logins, but it does not work. It keeps redirecting me to home.

    add_filter( ‘wp_bouncer_redirect_url’, ‘my_wp_bouncer_redirect_url’ );

    function my_wp_bouncer_redirect_url( $return_url )

    { $return_url = home_url( ‘/slug-costum-page/’ );

    return $return_url; }

    can you help me?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @electronica23 , thanks for reaching out.

    Please try changing the priority of the hook to something later such as:

    add_filter( "wp_bouncer_redirect_url", "my_wp_bouncer_redirect_url", 99, 1 );

    And add the code to your theme’s functions.php file and let me know if the issue persists?

    I suspect with it being in a Code Snippet it might be running too late for the redirect to be changed.

    Thread Starter electronica23

    (@electronica23)

    Hello Jarryd, thank you for your prompt response.

    I added the code to the functions.php file and it does not work, it still does not redirect to the specific page and it takes me directly to the home page.

    I do not know what to do

    Using the home_url seems to be problematic in this case. Please replace the $return_url value with either:

    1. The full URL to which you want the user to be redirected to
    2. get_the_permalink( 99 ); where 99 is the page ID you want to redirect to

    Please let me know if the above helps.

    Thread Starter electronica23

    (@electronica23)

    Hi, i replace the $return_url value with both alternatives in funtions.php file, and it doesn’t work, it keeps redirecting to the homepage.

    Adding get permalink:

    add_filter( “wp_bouncer_redirect_url”, “my_wp_bouncer_redirect_url”, 99, 1 );
    function my_wp_bouncer_redirect_url( $return_url ) {
    $return_url = get_the_permalink( 9 );
    return $return_url;
    }

    Adding full URL:

    add_filter( “wp_bouncer_redirect_url”, “my_wp_bouncer_redirect_url”, 99, 1 );
    function my_wp_bouncer_redirect_url( $return_url ) {
    $return_url = “https://my-url.com/sign-out “;
    return $return_url;
    }

    I’ve tested the same code locally on my side but it’s working for me – I can’t replicate what you’re experiencing.

    function my_wp_bouncer_redirect_url( $return_url ){ 
    
    	$return_url = get_the_permalink(32);
    
    	return $return_url; 
    }
    add_filter( 'wp_bouncer_redirect_url', 'my_wp_bouncer_redirect_url' );

    Have you tried running this in a Code Snippets plugin again? I ran this from a custom plugin instead of a theme file and it worked for me.

    Thread Starter electronica23

    (@electronica23)

    Possibly it’s because I have a redirect to the homepage when users log out with de plugin “LoginWP (Formerly Peter’s Login Redirect)”. There may be a conflict and I take that priority. We would have to see how that is coded.

    That might be causing a conflict – perhaps try temporarily deactivating that plugin and run a test, and see if the issue persists.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wp_bouncer_redirect_url is not working’ is closed to new replies.