Support

Account

Home Forums Front-end Issues Front-end Form: Redirect after Save Reply To: Front-end Form: Redirect after Save

  • @endcore or someone i need some help immediately.I can’t redirect after user submit the form

    <?php
    acf_form_head();
    ?>
    <?php
    $args = array(
    ‘post_id’ => ‘new_post’,
    ‘new_post’ => array(
    ‘post_type’ => ‘corona_data’,
    ‘post_status’ => ‘publish’
    ),
    ‘submit_value’ => __(‘Αποστολή’)
    );
    acf_form($args);
    ?>

    and my function in functions.php

    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
    function my_pre_save_post( $post_id ) {
    global $post;

    if($post->post_name == ‘some-post’) {
    $post = array(
    ‘post_status’ => ‘publish’ ,
    ‘post_title’ => ‘some-title’,
    ‘post_type’ => ‘some-post-type’,
    );
    // Create a new post

    // insert the post
    $post_id = wp_insert_post($post);

    // update custom field

    do_action(‘acf/save_post’, $post_id);

    //do_action(‘acf/save_post’ , $post_id);

    wp_redirect(‘https://coronavirus.crowdapps.net/stoixeia-forea/&#8217;, 301);
    exit;
    }
    }