Home Forums ACF PRO Front End Publish or Draft


Front End Publish or Draft

  • Hi

    Using ACF Pro, we have a front end form for cpt, and want users to be able to save either a draft or publish from the front end. I have followed a few threads and not been able to get this working, have tried the following to no avail. Hoping someone can point me in the right direction:

    function my_pre_save_post( $post_id ) {
    	// check if this is to be a new post
        if( $post_id != 'new' ) {
            return $post_id;
        // is checkbox field checked?
        if (isset($_POST['acf']['field_5afdd74180e8c'])) {
        	$status = 'draft';
        } else {
        	$status = 'publish';
        // Create a new post
        $post = array(
    		'post_status' => $status,
    		'post_type'   => 'attractions',
    		'post_title'  => true,
        // 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 );
  • Hi @tonymu

    Does the form appear?

    What kind of errors are reported?

    Are you on the Pro or the free version?

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

The topic ‘Front End Publish or Draft’ is closed to new replies.