Support

Account

Home Forums ACF PRO FR: acf_form return to permalink Reply To: FR: acf_form return to permalink

  • For some reason I can’t get this to work, The page is getting created, but I get redirected to a blank page, my current Front End page looks like:

    
    <?php                    
      $args = array(
        'post_id' => 'new_1',
        'field_groups' => array( 357 ),
        'submit_value' => 'Submit Story', 
        'return' => '%post_url%?foo=bar'
       );
    acf_form( $args );
    ?>
    

    And My Functions File:

    
    //ACF FORM ARGUMENT
    function my_pre_save_post( $post_id )
    {
        // check if this is to be a new post
        if( $post_id != 'new_1' )
        {		
    		return $post_id;
    	}
    	
    	// Create a new post
    	$post = array(
    		'post_status'  => 'publish' ,
    		'post_title'  => $_POST['fields']['field_54f5894e01b06'],
    		'post_content'	=>	$_POST['fields']['field_54f5897401b07'],
    		'post_type'  => 'shortstory',
    		'post_parent'   =>  $_POST['fields']['field_54f596ac44e2b']
    	);  
    
    	// insert the post
    	$post_id = wp_insert_post( $post ); 
    	
    	// update $_POST['return']
    	$_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
      
    	return $post_id;
    }
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    

    Any help would be much appreciated.