Posted: December 10, 2014 at 2:21 pm
|
I am using EE3 to manage pick up hockey games. Users can sign up for a game, and choose which of two teams they want to play on. I track attendee numbers because there is a limit to how many players can be on each team. I’m using questions to track team choice. I was thinking of using conditional logic to hide the team selection box when that team’s limit has been reached. Any other ideas of how to handle this? Thanks! |
Hi, Are you currently having players register for multiple games at once? If not, then Event Espresso 4 would be a better fit since you could set a limit on the number of registrations for each team. — |
|
|
I would make 2 events, 1 for each team, and use a category to group the two team “events” together. Is there particular EE3 functionality that hasn’t been added to EE4 yet that is keeping you from using EE4? There it would be easy to make 2 tickets for the same event, and limit the number by the ticket. |
|
Thanks for the feedback. This is my first time using EE and I recommended it to my client, and I absolutely think it’s the right choice. I needed to use the WP Users add-on which is why we didn’t get EE4. I think I’ll try playing with groups and see if I can get it to work the way the client wants. Otherwise I think messing around with the template is unfortunately going to be the answer. |
|
Is it specifically the member’s only pricing? |
|
Yes, you have to be a member to sign up for a game |
|
Okay, this is probably not the best way to do this, but this is what I’ve come up with: The choice of teams (white, dark) was created in Questions and is displayed as a required radio button selection during event registration. I created a new table (team_tally) that includes event_id, white, dark where white and dark are (int) representing the number of players on each team. When a new event is created, it triggers code which inserts a new row into the team_tally table with the event_id,0,0 Each game has an attendee limit. Therefore I’ll set the limit of players on each team to be the attendee limit /2 Before I display the event registration form, I will check the team_tally table for the current number for white and dark based on the event_id. If the tally for either team is >= attendee limit/2, I will disable that team’s radio button and checked=”checked” the other team’s button, forcing players onto the team that still has room. This logic is contained in the custom_functions.php file in the event_form_build() function. The idea is that when someone registers for an event, it will trigger code which increments by one their choice of team in the team_tally table. There will be a corresponding decrement if they cancel registration. So here is where I need some expert insight. It seems to me that in order to trigger my code when a new event is created, I have to modify the insert_event.php file. I’ve been able to successfully select the event_id and insert a new row into team_tally table from within the insert_event.php file. Is there any way to move these custom functions out of the core file and into the custom_functions.php? I tried putting a function to insert the row in custom_functions.php and calling it from insert_event.php, but it doesn’t work; the insert code only works from inside insert_event.php Also, in order to increment the team_tally I’ll need to be able to trigger a custom function when the event registration occurs which I believe will be in the add_attendees_to_db.php file. I’ll capture their team choice and increment the corresponding team in the team_tally table accordingly. Obviously I’d like to move as much custom programming out of the core insert_event.php and add_attendees_to_db.php files as possible. Any suggestions? Let me also add that I really appreciate how well all the EE3 code has been commented. It makes what feels like a daunting task feel quite a bit less daunting! Thanks. |
|
I would do it as pieces of Event Meta. There is a simple little function that you can override that sets the defaults for new events. So insert four new meta fields with keys team_tally_white, team_tally_black, team_limit_white, team_limit_black. That way all the admin, insertion and retrieval from the db is done for you. There are action hooks available that fire after an attendee is saved to the db, so you could do your incrementing there, using the EE functions that get and set the Event Meta. So all your custom code would be outside of core, some in a custom functions plugin, some in templates in the uploads folder. |
|
Thanks for the advice Sidney. The functionality of the Event Meta is exactly what I need – now I just have to add the incrementing function. Could you give me the names of the action hooks and EE functions I should be looking at, to save me having to pour through all the code trying to figure it out? Thanks!!! |
|
Hello again. Thanks to your suggestions Sidney, I was able to use the action hooks and custom functions to keep track of the number of players on each team, and move all of my code out of the plug-in files. Thanks! Last step – I need to trigger a function that reduces by one the tally for a team when an attendee is deleted from the db by the actions of either an admin or the attendee. I found this action hook which looks promising: Is this only triggered when the admin deletes an attendee? Is there anything that will signal the cancellation and deletion by the attendee himself? Any suggestions on how to cover all bases? Thanks. |
|
Any suggestions? Please? |
|
I think the only way an attendee can delete themselves is in the “My Events” page that is in the WP-User integration add-on for EE3. |
|
Just a quick follow up to say thanks to Sidney for all your help. Your suggestion about using the event meta data for tracking worked out great, and I was able to add some code so that the roster was properly updated when users cancelled their registration for an event (it was inside the WP-User addon). Event Espresso is an awesome plugin, and I can’t wait for an opportunity to work with EE4! |
|
Thanks for the feedback! I’ll let Sidney know that you got this up and running. If you want to share the love, there are plenty of ways you can do so: https://eventespresso.com/about/help-us-help-you-how-to-share-event-espresso/ |
The support post ‘One game, two teams – limit attendees’ 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.