Home › Forums › General Issues › update_field on a relationship field › Reply To: update_field on a relationship field
I’m not sure where I’m going wrong but I can’t seem to get it to work for me;
add_action("gform_after_submission_2", "acf_post_submission", 10, 2);
function acf_post_submission ($entry, $form) {
//if the Advanced Post Creation add-on is used, more than one post may be created for a form submission
//the post ids are stored as an array in the entry meta
$created_posts = gform_get_meta( $entry['id'], 'gravityformsadvancedpostcreation_post_id' );
foreach ( $created_posts as $post ) {
$post_id = $post['post_id'];
// Do your stuff here.
echo "<br />Post ID: " . $post_id;
$values = rgar( $entry, '11' );
echo "<br />Billing Entity: " . $values;
// get current value
$value = get_field('billing_entity', $post_id, false);
// add new id to the array
$value[] = $values;
// update the field
update_field('field_66b0d39eed031', $value, $post_id);
}
}
The relationship field doesn’t update.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.