Support

Account

Home Forums Front-end Issues Repeater and Flexible Fields not Saving Values from FrontEnd Reply To: Repeater and Flexible Fields not Saving Values from FrontEnd

  • Been testing.

    I added your field groups to one of my test sites

    I set the location for both field groups to appear on posts

    I created a font end form that shows on all pages

    I added this following the the top of my page template

     
    add_filter('acf/pre_save_post' , 'tsm_do_pre_save_post' );
    function tsm_do_pre_save_post( $post_id ) {
    
    	// check if this is to be a new post
    	if( $post_id != 'new' ) {
    		return $post_id;
    	}
    
    	// Create a new post
    	$post = array(
    		'post_type'     => 'post', 
    		'post_status'   => 'pending', 
    		'post_title'    => wp_strip_all_tags($_POST['acf']['field_559a8e6366915']), // Post Title ACF field key
    		'post_content'  => $_POST['acf']['field_559a8e7b66916'], // Post Content ACF field key
    	);
    
    	$post_id = wp_insert_post( $post );
    	
    	wp_set_object_terms($post_id, array(1829), 'category');
    	
    	// ACF image field key
    	$image = $_POST['acf']['field_559a8eb766918'];
    
    	// Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	add_post_meta( $post_id, '_thumbnail_id', $image );
    
    	return $post_id;
    	
    }
     
    acf_form_head();
    
    get_header(); ?>
    

    And I used the following to show the form, I reduced this to just what was needed to test it.

    
    $new_post = array(
    	'post_id'            => 'new', 
    	'field_groups'       => array(4,8), // different id values here
    	'uploader' 			 => 'basic'
    );
    
    acf_form( $new_post );
    

    Notes, I did not use the location rules to only show the first group for admins, just showed it on the page.

    I then went to a front end page and added data to every field, I created serveral flex fields. Everything was saved to a new post as expected.

    I used an site that only has ACF installed, no other plugins. I was using the 2014 theme.

    There must be something else causing the issue of the content not saving.

    Deactivate other plugins and see it that helps. If not try switching to a defualt WP theme and see if that helps (you”ll need to add your form code to the default theme)