How to check checkbox-status in "before_send"-Function?
-
Hello,
I’ve build a form with several checkboxes with “Contact Form 7”.
Each checkbox stands for an event with a price which the user can select (e.g. “Sightseeing-Tour in Berlin – 10 Euro”).
After the user presses the “submit”-button a function should add the prices for the choosen events and write the sum in the email, which will be send automatically from Contact Form 7 to the user.
My problem: how can I check in the function whether a chechbox is checked or not? I have tried the following code which does not work:
add_action('wpcf7_before_send_mail', 'wpcf7_calculate_sum'); function wpcf7_calculate_sum ($WPCF7_ContactForm) { $total_sum=0; if ($WPCF7_ContactForm->posted_data['checkbox01'] == 1) { $total_sum = $total_sum + 1; } if ($WPCF7_ContactForm->posted_data['checkbox02'] == 1) { $total_sum = $total_sum + 2; } $WPCF7_ContactForm->mail['body'] .= 'Total sum = '.$total_sum.' Euro</p>'; }
These comparisons do not work, the result ist always FALSE, so the total sum will always be zero.
Any idea?
Thank you for your help in advance!
Michael
- The topic ‘How to check checkbox-status in "before_send"-Function?’ is closed to new replies.