Support

Account

Home Forums General Issues Create post from acf_form in other post type and set custom fields Reply To: Create post from acf_form in other post type and set custom fields

  • OK, I managed to do it with a acf/save_post function.

    add_filter('acf/save_post', 'create_proposal_from_form');  
    
    function create_proposal_from_form($post_id) {
    	
    	$test = get_field('test',$post_id);
    	$pagetype = is_page_template();
    	
    	if ($pagetype = 'Proposal Form') {
    		
    		$post_data = array(
    				'post_title' => 'Test7', 
    				'post_status' => 'publish',
    				'post_name' => 'test1',
    				'post_type' => 'enquiry',
    			);
    
    		$newpageid = wp_insert_post( $post_data );	
    		update_field('form_event_nights',$test, $newpageid);	
    	}
    }