Support

Home Forums Event Espresso Premium Disable radio button option based on number of registrations

Disable radio button option based on number of registrations

Posted: March 4, 2020 at 9:29 am

Viewing 1 reply thread


ERA-ICTRegistration

March 4, 2020 at 9:29 am

Hi! I have a radio button selection in my registration form for enrollment to workshops, for which I need to disable the option once maximum capacity is reached which can differ per option.
What would be the most appropriate solution to implement this?
I thought about adding a plugin with a function that validates the sum of registrations to each workshop against max capacity, which can differ per option.
What would be the most appropriate solution to implement this?
I thought about adding a plugin with a function that validates the sum of registrations to each workshop against max capacity. Any recommendations?


Josh

  • Support Staff

March 19, 2020 at 3:25 pm

Hi,

This would require some significant custom plugin development.

I can point you in the direction of where you can hook in via filter hook and programmatically alter the radio button options. Here’s a link to the source for context: https://github.com/eventespresso/event-espresso-core/blob/55edba0b68c8e34983845a981669665874398fdc/core/db_classes/EE_Question.class.php#L661

So for example the function could start out as:

add_filter(
  'FHEE__EE_Question__generate_form_input__return',
  'my_custom_function',
  10,
  4
);
function my_custom_function(
  $result,
  $registration,
  $question,
  $answer
) {
    // Add logic here
    // you have access to the $registration, $question, and $answer objects
  return $result;
}

With access to the 3 objects listed above you can get just about any related data you’ll need to perform the logic of checking number of existing answers in the database and so on. We recommend using the built-in model system for retrieving that data.

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

Viewing 1 reply thread

The support post ‘Disable radio button option based on number of registrations’ 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