Home Forums Event Espresso Premium How to handle registration form error display elegantly

How to handle registration form error display elegantly

Posted: August 19, 2020 at 5:34 pm

August 19, 2020 at 5:34 pm

Greetings – I have an event registration form with four fields: First Name, Last Name, Email Address, and Company Code. The Company Code had to be added as a new “question” of type text.

I would like to compare this input Company Code to a Company Code that is provided on the Event page itself via Custom Field. If they don’t match I would like to highlight the field and put an error message underneath it (just like your default behavior for required fields)

So here is a snippet of code in my submit override method in my PHP plugin:

// Check if the event client code matches the input client code
// Get the target client code
$targetCode = get_post_meta($event->ID(), ‘max_client_code’, true);
error_log(print_r(‘TARGET CODE: ‘ . $targetCode, true));

// Get the input client code
#inputCode = $registration->answer_value_to_question(12);
error_log(print_r(‘INPUT CODE: ‘ . $inputCode, true));

// Then compare them and if they don’t match display a field level error

Hopefully you get the idea. So how can highlight the field and display an error message underneath it in PHP if the 2 codes don’t match? OR is there a better way to implement this that I am not seeing?

Thanks in advance,


  • Support Staff

August 20, 2020 at 9:28 am

Hi there,

Sounds like you could use the FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process hook to do what you are requesting.

That allows you to stop processing and return an error onto the page, you can also specify which field your error should target.

Take a look here:

August 26, 2020 at 12:26 pm

You mention above “you can also specify which field your error should target”
Can you please expand on this? How do I go about doing this and how do I tie the hook to CSS to highlight the field in error like you do with required fields on the registration form.

Thanks, Mark


  • Support Staff

August 28, 2020 at 4:54 am

Mark, my apologies.

I checked into this further and realised that for the above you also need to add your own JavaScript on the Single Page Checkout page (SPCO for short) and include additional details to return the error which is then used by your JavaScript.

You can see this in action within our WP user integration add-on HERE

Which then uses it’s own JS loaded on SPCO, see HERE

What you may be better doing is using some PHP to add the events meta value to the DOM/global JS var, then add your own JS with a listener on the Company question. Compare the value on change with the meta value you added to the page earlier, disable the submit button if invalid and/or add the message to the field.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 2 months ago ago

Topic Tags


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!