Hello,
Thanks for the feedback!
Unfortunately the ACFE Form doesn’t let you update a specific ACF Field value using a Template Tag from the UI at the moment. Template Tags can be only used in the ACFE Form UI settings, and within each Actions fields (such as Post Title, Post Content etc… for the Post Action).
The workaround you found is quite ingenious, but there’s an easier way to achieve this in PHP.
In fact when using any ACFE Form hooks, such as the Post Action Submit acfe/form/submit/post
(See documentation), you’ll have access to the $form
dataset, which contains your specific $form['my_data']
.
Using that value, you can update an ACF field programmatically with update_field()
.
Here is a usage example:
add_action('acfe/form/submit/post/form=my-form', 'my_form_submit', 10, 5);
function my_form_submit($post_id, $type, $args, $form, $action){
// retrieve 'my_data' from the $form dataset (aka: {form:my_data})
$my_data = $form['my_data'];
// update 'my_field' with 'my_data' value on the newly created 'post_id'
update_field('my_field', $my_data, $post_id);
}
Hope it helps!
Have a nice day!
Regards.