Support

Account

Home Forums ACF PRO Custom Post Title with Front End Form ? Reply To: Custom Post Title with Front End Form ?

  • I’v tried adding this to the head of my template file (and also in functions.php) but still no title is created?

    		function my_pre_save_post( $post_id ) {
    
    		/*var_dump( $post_id ); // OUTPUT: NULL
        var_dump( $_POST['post_id'] ); // OUTPUT: string(3) "new"
        die();*/
        			
    			if ( $post_id != 'new_post' ) {
    				return $post_id;
    			} 
    			
    			$post = array(
    				'post_title' => 'A custom title',
    			);
    			
    			$post_id = wp_insert_post( $post );
    			
    			return $post_id;
    			
    		}		
    		add_filter( 'acf/pre_save_post', 'my_pre_save_post', 10, 1 );

    Any other ideas?

    Thanks for the help.