ACF pre_save_posts submitting on page load

Question

I have a form using all ACF fields. I want to submit the form to a custom post type and set the title. However when I just load the page, the form is submitting. I’m using the same example off of the ACF website.
Here’s my code:

  function instructor_time_title( $post_id ) {
      if( $post_id != 'new' ) {
        return $post_id;
      }

      // Create a new post
      $post = array(
        'post_status'  => 'publish' ,
        'post_title'  => 'A title, maybe a $_POST variable' ,
        'post_type'  => 'post' ,
      );  

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

      // return the new ID
      return $post_id;
    }
    add_filter( 'acf/pre_save_post' , 'instructor_time_title', 10, 1 );

Any and all help is appreciated!

0
, lz430 3 years 2020-04-07T16:51:09-05:00 0 Answers 81 views 0

Leave an answer

Browse
Browse