Support

Account

Home Forums Front-end Issues Allow 'save to draft' and 'publish' on front end form Reply To: Allow 'save to draft' and 'publish' on front end form

  • @hube2 I tried the above suggestion but post_status is not being set correctly – it still sets the post as published.

    function my_pre_save_post( $post_id ) {
    
      // check if this is to be a new post
      if( $post_id != 'new_post' ) {
        return $post_id;
      }
    
      // Create a new post
      $post = array(
        'post_status'  => $_POST['acf']['field_58aa9af6e90cd'],
      );
    
      // insert the post
      $post_id = wp_insert_post( $post ); 
    
      // return the new ID
      return $post_id;
    
    }
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );

    In my case, the field field_58aa9af6e90cd returns either ‘draft’ or ‘publish’

    Am I missing something?