Support

Account

Home Forums General Issues acf_form not saving data when editing on frontend

Helping

acf_form not saving data when editing on frontend

  • Hi!

    I’m using an acf_form to have a user create a post, which works no problem. But when the user needs to edit the post info, it shows the acf_form but all the fields are empty, causing the user to have to reinput everything all over again. Is there a way to have the fields populated with the previously inputted info when they edit?

    Here’s my acf_form code:

    
    <?php
    
    /*
    Template Name: Preferred Agent Form
    
    */
    
    acf_form_head();
    get_header();
    
    ?>
    
    <div class="fl-content-full container">
    	<div class="row">
    		<div class="fl-content col-md-12">
    			<?php
    			acf_form(array(
    				'post_id'             => 'new_post',
    				'post_title'          => true,
    				'field_groups'        => array(555),
    				'form'                => true,
    				'html_before_fields'  => '',
    				'html_after_fields'   => '',
    				'submit_value'        => 'Submit Information', 'acf',
    				'updated_message'     => 'Saved!',
    				'honeypot'			=> true,
    // 				'return' => add_query_arg( 'updated', 'true', home_url() ),
    				'new_post'            => array(
    					'post_type'   => 'preferred_agent',
    					'post_status' => 'pending'
    				)
    			));
    			?>
    		</div>
    	</div>
    </div>
    
    <?php get_footer(); ?>
    

    Any help on this would be awesome. Thanks!

  • Hello:

    Once the post has been created, to allow the user to edit the data instead of passing “new_post” as the value for post_id you need to pass the id of the post. When the post id is passed, the form will load the existing data for editing.

    Hope this is helpful!

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

The topic ‘acf_form not saving data when editing on frontend’ is closed to new replies.