Hi,
I'm trying to increment a number value by 1 in ACF field 'rb-huidig_aantal_deelnemers' of the current post after creating a FF entry.
The current post is where the FF form is displayed. I managed to figure out this script, but the value in the field does not change.
The ACF field type is Number.
Can anyone help me out here maybe? Thanks in advance!
add_action('frm_after_create_entry', 'update_post_after_form_submission', 30, 2); function update_post_after_form_submission($entry_id, $form_id){ if ($form_id == 6) { // Aanmelding Training form ID $post_id = get_the_ID(); // Gets the ID of the current post if (!$post_id) { return; // Exit if no post ID found } $current_value = get_field('rb-huidig_aantal_deelnemers', $post_id); $new_value = intval($current_value) + 1; // Update custom field called 'rb-huidig_aantal_deelnemers' update_field('rb-huidig_aantal_deelnemers', $new_value, $post_id); } }
<p>Thanks for helping out and giving more insight, Victor! I already managed to get it working, by storing the post_id in a form field. Get the id goes like this:</p><p>$id = $_POST['item_meta'][117];</p>
Please login or Register to submit your answer