Support

Account

Home Forums General Issues Submission button/wp_redirect() not working

Helping

Submission button/wp_redirect() not working

  • Hey,

    So, I have a review form, wherein a user is guided through a process of writing a review, and at the end, there is an overview with a submit button. The process then forks — with any review over a 9/10 being sent to landing page 1, and 8/10 or lower being sent to landing page 2.

    Here’s the function:

    //acf review form redirect
    function my_acf_save_post( $post_id )
    {
    		$values = get_field('rating', $post_id);
            if ($values == '4.5' || $values == '5'){
            	wp_redirect('/reviews/thank-you'); exit;
            } else{
            	wp_redirect('reviews/thank-you-bd'); exit;
            }
    }

    The problem I’m encountering is that when you click submit on the final step, the button does not seem to do anything. Based on reading through this forum and the wordpress forum, I’ve done the following:

    1.) Opened console log on the page to check for JS errors, but none present themselves. Pretty sure it’s not JS affecting this issue.

    2.) Tried to change the wp_redirect() from wp_redirect(‘/example-url-1/’) to wp_redirect(home_url() . ‘example-url-1’) ; I’ve also put in wp_redirect(‘www.example.com’) to see if syntax is an issue on the redirect. I have also used an unreleated URL to see if there is an issue with redirecting to a page on the website, but the redirect just doesn’t seem to do anything at all.

    3.) The wp_redirect does not seem to a.) be working or b.) perhaps I have it completely wrong.

    4.) Based on the other forums, I’ve triple checked the page template php files, and they all have <?php acf_form_head(); ?> before <?php get_header(); ?>

    If anyone has experienced something similar, I’d appreciate any insight you might have. Thanks in Advance!

  • Did you et this solved?

    Are you sure your filter is being called?

    
    function my_acf_save_post($post_id) {
      die('my action was called');
    

    If not, where are you adding add_action('acf/save_post', 'my_acf_save_post');

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.