Hello,
Thanks for the feedback!
The best way to update some fields programmatically, based on some condition, is to handle this logic from code.
Instead of selecting which ACF fields to update from the Post Action in the Form UI, you’ll have to update them via update_field() (see documentation) in the acfe/form/submit/post hook (see documentation), if you’re creating/updating a post, and add your condition there.
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){
// get the form input values (unformatted)
$my_text = get_field('my_text', false, false);
$my_email = get_field('my_email', false, false);
// custom condition example
// add your own logic here
$should_update = true;
// check our condition
// fields should be updated?
if($should_update){
// update fields programmatically
// on the creapted/updated post: $post_id
update_field('my_text', $my_field, $post_id);
update_field('my_email', $my_email, $post_id);
}
}
Hope it helps!
Have a nice day, and a happy holiday season!
Regards.
Thread Starter
Anonymous User 13711045
(@anonymized-13711045)
In the section where I can grab the form inputs using get_field, are the values passed to that sanitized already? Or is it just the raw input?
Hello,
Yes, in this section, values are already sanitized (and validated via ajax too).
Regards.