How to redirect a user after a confirmed appointment to a thank you page when payment is not req

Hi Guys

I need to direct a user to a thank you page after they have made an appointment. I have tried adding the recommend code to my sites function.php file

function app_redirect( $script ){
    return str_replace("window.location.href=app_location()", "window.location.href='http://example.com'", $script);
}
add_filter( 'app_footer_scripts', 'app_redirect' );

but when ever I do this its stop the entire site from loading? Am I adding it in the the wrong file or place? please help!

Thanks
Fran

  • Francesco

    Hi Michelle,

    Thanks for getting back so..

    I got the code from the FAQ's on the pluggin and I am putting the code on the last line of the functions.php file. The code above is

    /**
     * Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN ).
     *
     * @since 4.0.0
     *
     * @param mixed $var Boolean value to validate.
     * @return bool Whether the value is validated.
     */
    function wp_validate_boolean( $var ) {
    	if ( is_bool( $var ) ) {
    		return $var;
    	}
    
    	if ( 'false' === $var ) {
    		return false;
    	}
    
    	return (bool) $var;

    I hope this helps

  • Francesco

    Hi Michelle

    So I made sure the curly brackets where all in place like this:

    function wp_validate_boolean( $var ) {
    	if ( is_bool( $var ) ) {
    		return $var;
    	}
    
    	if ( 'false' === $var ) {
    		return false;
    	}
    
    	return (bool) $var;
    }
    
    function app_redirect( $script ){
        return str_replace("window.location.href=app_location()", "window.location.href='http://example.com'", $script);
    }
    add_filter( 'app_footer_scripts', 'app_redirect' );
    }

    This gave me the same problem of the site not loading! I then removed the curly bracket from the last line as the code provided did have one like this:

    function wp_validate_boolean( $var ) {
    	if ( is_bool( $var ) ) {
    		return $var;
    	}
    
    	if ( 'false' === $var ) {
    		return false;
    	}
    
    	return (bool) $var;
    }
    
    function app_redirect( $script ){
        return str_replace("window.location.href=app_location()", "window.location.href='http://example.com'", $script);
    } 
    
    add_filter( 'app_footer_scripts', 'app_redirect' );

    And we had the same problem so..... I removed the last line like this:

    function wp_validate_boolean( $var ) {
    	if ( is_bool( $var ) ) {
    		return $var;
    	}
    
    	if ( 'false' === $var ) {
    		return false;
    	}
    
    	return (bool) $var;
    }
    
    function app_redirect( $script ){
        return str_replace("window.location.href=app_location()", "window.location.href='http://example.com'", $script);
    }

    And the website loaded but when I made an appointment it didn't redirect me it just reloaded the appointment page??

    Thanks
    Fran

  • Michelle Shull

    Hey there, Fran!

    Thanks so much for testing this.

    Since you can access the site again, would you be willing to let me take a look around? If this is ok, just grant me temporary admin access to your site by clicking "Grant Access" button in the WPMU DEV Dashboard Settings from the following path and reply on this thread after granting it?

    Admin -> WPMU DEV -> Support -> Support Access Tab

    If you have not installed WPMU DEV Dashboard plugin yet, kindly do that here : https://premium.wpmudev.org/project/wpmu-dev-dashboard/ and then allow access as per the above process.

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.