Home › Forums › Calendar Products › Events Calendar PRO › Programmatically register user for event
- This topic has 4 replies, 2 voices, and was last updated 10 years, 8 months ago by
Geoff.
-
AuthorPosts
-
September 9, 2015 at 9:53 am #1003363
Joseph
ParticipantHi:
I’m using Events Calendar PRO in conjunction with WooCommerce tickets. Right now I’m using coupon codes to allow my members to register other members for events and achieve member discounts. I have coupon codes being created whenever new members sign up; these coupon codes match the users login and attach the user info to the order so my client’s billing dept can distribute tickets and match discounts to users.
Now I need a way to programmatically register users for the events after the payment has been processed for the order. I can easily retrieve the user ID# via the coupon code, but I can’t find a TEC function to register users by ID, name, etc. Is there an existing function or do I need to do a database action?
Alternatively, if I use WooCommerce to purchase the ticket programmatically for the user, will the user then be registered in TEC?
Thanks,
Joe
September 9, 2015 at 1:47 pm #1003479Geoff
MemberHi Joseph and good question!
Neither The Events Calendar or WooCommerce Tickets do anything with user registration in WordPress. Instead, WooCommerce Tickets will associate a purchase with the customer ID captured directly by WooCommerce, which is where all orders, customers and products are ultimately created and registered.
So, in that sense, it sounds like you would want to hook into the WooCommerce data for the customer id, then possibly query any associated products/events posts.
Let me know if that helps clarify anything and I’d be happy any other questions as best I can!
Geoff
September 9, 2015 at 2:35 pm #1003499Joseph
ParticipantHi Geoff,
Thanks for your response. Just to make sure I’m understanding correctly, essentially: if I wanted the attached users to be added as attendees, I would need to loop through the coupons on a given order after payment is processed for that order, then generate and complete orders for each coupon/user for that product/ticket. Once these automatic orders are completed in WooCommerce, the attendee will appear in the list for the event corresponding to that product/ticket. Correct?
Thanks!
Joe
September 9, 2015 at 3:30 pm #1003517Joseph
ParticipantFor anyone watching this thread, I’ve completed my task here.
I’ve used woocommerce_payment_complete to loop through coupons, grab users, and open/complete new orders for the same item(s) in the originating order. Once these orders are complete within WooCommerce, the user is properly “enrolled” for that event in the attendee list.
Joey
September 9, 2015 at 4:13 pm #1003528Geoff
MemberRight on, nice work Joseph! I’m stoked that you not only got that working but that you shared the answer with us here–I bet others will find that helpful!
Cheers,
Geoff -
AuthorPosts
- The topic ‘Programmatically register user for event’ is closed to new replies.
