Programmatically register user for event

Home Forums Calendar Products Events Calendar PRO Programmatically register user for event

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1003363
    Joseph
    Participant

    Hi:

    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

    #1003479
    Geoff
    Member

    Hi 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

    #1003499
    Joseph
    Participant

    Hi 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

    #1003517
    Joseph
    Participant

    For 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

    #1003528
    Geoff
    Member

    Right 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Programmatically register user for event’ is closed to new replies.