Support

Home Forums Event Espresso Premium Conditional text if field has value

Conditional text if field has value

Posted: March 12, 2024 at 9:34 am


adijeff

March 12, 2024 at 9:34 am

I know it is possible to add custom field data to receipts and invoices using [PRIMARY_REGISTRANT_ANSWER_*My Question] but is it possible to show text before the field value if the field has a value, but not show text if the field is left empty? Something like this php:
<?php if ( $my_question ) : ?>
My question: <?= $my_question; ?>
<?php endif; ?>

Thanks


adijeff

March 18, 2024 at 5:17 am

I guess this is not possible. Fortunately the client is happy with a field label showing on the invoice whether the user entered data or not.


Tony

  • Support Staff

March 18, 2024 at 7:14 am

Hi there,

My apologies for the delayed reply.

Currently, we don’t have any shortcodes that will conditionally show based on the value. However, all of the shortcodes within EE are filtered so its possible to add your own for this if needed.

https://eventespresso.com/wiki/messages-system-how-to-add-custom-message-shortcodes/

The primary registrant shortcodes are an instance of EE_Primary_Registration_Details_Shortcodes.

You could add something like:

[PRIMARY_REGISTRANT_QUESTION_ANSWER_*My Question]

Then pull in the answer, check for a value and if you have one pull in the question and display both the question and the answer, otherwise nothing.


adijeff

March 18, 2024 at 9:15 am

Thanks for the reply Tony. I’m glad there’s a way to do it, but at first glance, the coding is a little beyond me. But good to know it’s possible, if the client really wants it. Thanks


Rio

  • Support Staff

March 18, 2024 at 5:15 pm

Awesome, If you need anything, feel free to send us message again.

thanks

The support post ‘Conditional text if field has value’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso