I have multiple forms in Elementor (contained in posts), and by clicking on the submit button I want that the ACF numeric field for this specific post is counted down by one.
For this, I created a shortcode, and I added an action after submitting to my Elementor form, a redirect to an shortcode. The acf field in the backend contains a number, and I want to count it down by one, every time someone submits the form.
function counter() {
// Get the current value.
$count = (int) get_field('teilnehmeranzahl');
// Decrease it.
$count--;
// Update with new value.
update_field('teilnehmeranzahl', $count);
};
add_shortcode('counter', 'counter');
It would be great if someone has an answer, especially how I can count only for the specific post that contains the form which was submitted. Thank you very much