Problem:
When a user submits a CRED from, I need data within that form to either be deleted or saved depending on which option was chosen in a select field earlier in that same form.
The select field is called voyage-or-excursion and the field values saved to the database are simply 1 or 2.
If Option 1 is selected, I need the data in the field voyage-from-event to be deleted.
If option 2 is selected, I need the data to be saved.
I have tried a few variations of the below code but with no luck, it simply doesn't save anything to the field.
The add_post_meta function is tested and working, but does not work when the new IF functions are added for the select field. Can you advise on what may be the issue?
Solution:
How do you setup the select field "voyage-or-excursion", if it is a custom field created with Types plugin, you will need to add string "wpcf-" in the field slug, for example:
replace this line from:
if ( (!empty($_POST['voyage-or-excursion'])) && ( $_POST['voyage-or-excursion'] == '2' ) ) {
To:
if ( (!empty($_POST['wpcf-voyage-or-excursion'])) && ( $_POST['wpcf-voyage-or-excursion'] == '2' ) ) {
Relevant Documentation:
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Hong_Kong (GMT+08:00)
This topic contains 5 replies, has 2 voices.
Last updated by 6 years, 9 months ago.
Assisted by: Luo Yang.