At present, there isn't a convenient filter in place to do this so if you need to modify a field value during submission, you need to modify the $_POST superglobal directly.
// Note the priority of 5 used on this hook. This is so that the modification fires before Advanced Forms' handler which // fires on a priority of 10. add_action( 'init', function () { // Make sure a form was posted. if ( ! isset( $_POST['af_form'] ) ) { return; } // Check for the form key to only run this on a specific form. if ( $_POST['af_form'] !== 'form_63603dfd5f7d2' ) { return; } $field_1_key = 'field_63603df414f2a'; $field_2_key = 'field_63603e7514f2b'; // Check the value of field 1 matches a condition and if so, modify the value of field 2. if ( isset( $_POST['acf'][ $field_1_key ] ) and $_POST['acf'][ $field_1_key ] === 'some value' ) { $_POST['acf'][ $field_2_key ] = 'field 2 updated value'; } }, 5 );
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article