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


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

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  Josh 1 week, 3 days ago ago

Topic Tags

Notifications

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