Support

Account

Home Forums Backend Issues (wp-admin) Updating post not working

Solving

Updating post not working

  • While I don’t see any documentation on how to do this, and not sure if I can do this with ACF, but its a deal breaker for me if I can’t.

    I have a custom post type called ‘School’ with a bnch of custom fields. The CPT is displayed to the user as a profile, I need to give users the ability to edit their profile, in other workds I need theme to be able to edit the ACF fields associated with the profile.

    This is the code I’m using for the form, I am currently hard coding the profile post ID in this example, but normally I’d query the db for one post in which the UserID acf field matches the UserID of the logged in user. This works but when I make a change and click the ‘Save Changes’ button, instead of updating the current post, it creates a duplicate post. Its loading the correct info for the profile, but saving to a new post even tho I have the post_id hard coded….HELP!!!!!!

    <div class=”container emp-profile”>
    <div class=’acf-edit-post’>
    <?php
    acf_form (array(
    ‘post_id’ => 3720,
    ‘field_groups’ => array(1220),
    ‘form’ => true,
    ‘submit_value’ => ‘Save Changes’,
    ));
    ?>
    </div>

    </div>

  • adding ‘new_post’ => false,

    doesn’t work either even tho documentation indicates it should:
    /* (int|string) The post ID to load data from and save data to. Defaults to the current post ID.
    Can also be set to ‘new_post’ to create a new post on submit */
    ‘post_id’ => false,

  • It should be working and I don’t see anything in what you’ve posted that should stop it from working. There must be something on your site that is altering the post ID before it’s getting saved. There are too many possibilities to list, you need to somehow narrow down them down. Could be in the theme or in another plugin.

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

The topic ‘Updating post not working’ is closed to new replies.