When checkbox is ticked complete action.

By: David Costin | Asked: 08/03/2025
ForumsCategory: General questionsWhen checkbox is ticked complete action.
David Costin asked 6 months ago

I have a PHP script: where the entry in for A is copied and an entry is created in form B.  This action SHOULD occur only if the checkbox is ticked.

The checkbox function appears not to be working: A copy is created in Form B when the checkbox is not ticked

I attach the script.

David

Attachments

Rob LeVineRob LeVine
Staff replied 6 months ago

The script doesn't appear to be attached. I recommend using a code paste site, such as paste2.org, to share code because it's easier than this format to format the code and share it with others.

4 Answers
David Costin answered 6 months ago

Rob,Thanks for your prompt reply.  Hope this is what you want.https://paste2.org/swg1O04YRegardsDavid 

Rob LeVineRob LeVine
Staff replied 6 months ago

What is the value of "$checkbox_value" after the FrmEntryMeta::get_entry_meta_by_field call?

David Costin answered 6 months ago

The value of the checkbox field is 'Yes'.David

David Costin answered 6 months ago

Profuse apologies, the checkbox field is '1'

Rob LeVineRob LeVine
Staff replied 6 months ago

Then your code is doing what it's supposed to. If the field value is 1 then it doesn't satisfy the if statement, thus it doesn't return and creates the entry. if (empty($checkbox_value) || $checkbox_value != '1')

David Costin answered 6 months ago

Rob, Many thanks for your help, all is ok now.Regards David

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right