Posted: May 14, 2018 at 2:53 pm
|
Hi, I’m posting a solution to a feature I needed but was not able to find on the forum for the benefit of others who may also need it: removing the ability to register again / create a duplicate registration for an event. NOTE: I believe this solution only works for member-based sites. If you don’t require your registrants to be logged in prior to registering for an event, this solution may not work for you. On my site we don’t actually sell tickets, but rather use EE to limit the registrations/available seats for internal organizational trainings we conduct. As a result, employees must be logged in prior to registering for a class. But even then I noticed that a user who was already registered for an event could open that event page and register again (i.e. “purchase” another ticket using the “Register Now” button), thus creating a situation where a person could have duplicate registrations. It would not be uncommon for someone to register for a class, forgot they did, and then register again. My goal was to remove this possibility, so after some searches on the forum, I started with code by Josh Feck that checks the user record that I found here: https://gist.github.com/joshfeck/f73483e9df1f5ccc55f15a43fcecf463, and then added a line of code to the very bottom (which actually hides the section where the Register Now button would normally appear). So the whole thing looks like:
Josh might be able to offer a cleaner version of this, but thought I’d share for others who might need to achieve this in the meantime. |
|
PS – you would put this in your function.php file (presumably in your child folder to avoid being lost after and update. |
|
…well, I guess I’m not as clever as I thought. That last line of code hides the register button whether the person is already registered for the event or not. Josh – what did I miss? |
|
…I think I figured it out. Had an extra-set brackets I didn’t need. so the last part should look like…
|
Hi there, There’s a couple of changes I would recommend making to that snippet (although it should work just fine as is) as we now have some methods built into EE that will reduce the workload needed for this.
That’s fairly inefficient for what you are trying to do, it pulls all events related to the contact, loops over them all to pull the ID’s and builds an array of ID that is used later to search through. You only need to know if the user has just one registration on that event, right? So you can do something like this:
Pull the most recent registration for the current post (which in this case will be an event), if that function returns an EE_Regisitration object then the user has at least one registration on the event, meaning you can do:
Try something like this: https://gist.github.com/Pebblo/10669adfeea322ade3d96a38857fb46b Which should also cover cases where you also display the ticket selector on the event list itself and not just the single event page. It removes the action used to add the ticket selector from the post rather than hiding the tickets after they have been added, which is what the additional code at the bottom is for. As mentioned, Josh’s code will work fine as is with your changes, the above just uses some newer methods to pull the data easier so its up to you which one you prefer to use 🙂 |
|
|
Tony – I went ahead and replaced what I had with this version. Thank you. But during testing I discovered that if I cancel the registration, this message doesn’t really account for that. So I’m looking for some kind of tweak that incorporates the actual status of the registration; meaning that if the user’s registration is changed to “canceled,” is there a way to filter for that and have the return text incorporate the registration status? I.e. instead of “You are registered for this event!” maybe “You have already registered for this event, and your current registration status is X. If you need to request any changes to your registration, please contact the course administrator.” |
Sure, you have the EE_registration object so you ca use the I’ve updated my gist to include it: https://gist.github.com/Pebblo/10669adfeea322ade3d96a38857fb46b |
|
|
Works great – thank you! |
The support post ‘How to hide the Register Now button for those already registered’ 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.