Support

Account

Home Forums General Issues Editing the post and saving it as a "draft" using acf_form (frontend ACF) Reply To: Editing the post and saving it as a "draft" using acf_form (frontend ACF)

  • Since you are not creating a new post but are updating an existing post you can’t use the new_post argument to make the changes.

    What you need to do is create an acf/pre_save_post filter https://www.advancedcustomfields.com/resources/acf-pre_save_post/, this is a filter that is run during the save action for acf_form().

    In your filter you’ll need to update the status of the post

    
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1);
    function my_pre_save_post($post_id) {
      // test to make sure this is front end and the right post type
      // just in case
      if (is_admin() || get_post_type($post_id) != 'your-post-type') {
        return $post_id;
      }
      $args = array(
        'ID' => $post_id,
        'post_status' => 'draft'
      );
      wp_update_post($args);
      return $post_id;
    }