Home › Forums › Ticket Products › Event Tickets Plus › How Can I Programmatically Register (RSVP) An Attendee
- This topic has 8 replies, 2 voices, and was last updated 8 years, 9 months ago by
Tim.
-
AuthorPosts
-
July 3, 2017 at 1:59 pm #1315621
Tim
ParticipantHey guys! First off thanks for a great plugin– I have used the free version for many sites. For this particular site I needed some of the features of both Calendar Pro and Even Tickets Plus, so that is what I am working with.
My questions is: How can I hook/what function provides the functionality for me to register an attendee programmatically? I want to hook the registration of the attendee with a CF7 form. Assume that I can get whatever arguments the function needs. What is the actual function that will accomplish this? I took a brief look through the source but figured I would just ask the devs.
Thanks!
July 4, 2017 at 3:17 pm #1316040Barry
MemberHi Tim,
Thanks for contacting us!
I don’t have great news to share, unfortunately. Right now this is possible and the method you would be interested in is
Tribe__Tickets__RSVP::generate_tickets() … however, this was built to inspect the $_POST superglobal and build the attendees/tickets from there.I’ll make a note for us to revisit this, but right now I’m afraid that to lever this method you would need to overwrite (and restore) the $_POST superglobal.
July 4, 2017 at 9:59 pm #1316152Tim
ParticipantThanks for the reply!
How does the generate_tickets() function get called? I see that the RSVP form has a blank action field so the form should just call itself correct? Or does the RSVP under the Tribe directory call the rsvp.php in the view directory.
So essentially what I would need to do is to post the correct variables and then call generate_tickets() which would then trigger the creation of a new attendee?
I think I did solve the problem with the code below (just manually added in the mapping for the ACF fields upon attendee creation), but I would like to know what you mean for future reference as well!
`// Collect Form Info
$first_name[‘value’] = empty($_POST[‘first-name’]) ? ” : $_POST[‘first-name’];
$last_name[‘value’] = empty($_POST[‘last-name’]) ? ” : $_POST[‘last-name’];
$gender[‘value’] = empty($_POST[‘menu-808’]) ? ” : $_POST[‘menu-808’];
$dob[‘value’] = empty($_POST[‘date-300’]) ? ” : $_POST[‘date-300’];
…
inserts post
…// Assign ACF Keys Info
$first_name[‘key’] = “first_name”;
$last_name[‘key’] = “last_name”;
$gender[‘key’] = “gender”;
$dob[‘key’] = “date_of_birth”;// Update Fields
update_field( $first_name[‘key’], $first_name[‘value’], $attendee_id );
update_field( $last_name[‘key’], $last_name[‘value’], $attendee_id );
update_field( $gender[‘key’], $gender[‘value’], $attendee_id );
update_field( $dob[‘key’], $dob[‘value’], $attendee_id );July 4, 2017 at 10:01 pm #1316153Tim
Participant** Only thing I am worried about with the above code is potential updates that would overwrite it as I just have that code stuffed inside the generate_tickets function.
July 5, 2017 at 6:04 am #1316230Barry
MemberHi Tim!
I’ll note that – for custom dev questions specifically – the amount of assistance we can provide does tend to be limited, but let me see if I can answer at least a few of your questions.
- Tribe__Tickets__RSVP::generate_tickets() runs pretty early in the request (when WordPress fires its template_redirect action) and basically just “listens” for the submission of new RSVPs by seeing if the expected data is present in the $_POST superglobal
- I definitely don’t recommend you modify any of our plugin code for the same reason you stated – it will be overwritten on the next update: containing your changes in a custom plugin makes more sense 🙂
- Though not ideal, they way I might approach this is altering $_POST directly, then calling Tribe__Tickets__RSVP::generate_tickets() to create the tickets/attendees, then performing any further manipulation based on the values of any ACF fields that might have been submitted (or whatever) after the method has run
- You can capture the newly created attendee ID by setting up an action that runs during event_tickets_rsvp_ticket_created (your callback will be provided with the attendee ID as the first parameter
I hope that helps — and good luck with the project!
July 5, 2017 at 11:00 am #1316409Tim
ParticipantThanks a lot for the help!
July 5, 2017 at 3:01 pm #1316497Barry
MemberYou’re welcome 🙂
July 27, 2017 at 9:35 am #1326960Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘How Can I Programmatically Register (RSVP) An Attendee’ is closed to new replies.
