Support

Home Forums WP User Integration Register user via API call

Register user via API call

Posted: October 22, 2019 at 11:04 am


setarnv

October 22, 2019 at 11:04 am

I want to make an event application that allow users to (un)register for events. I have reviewed the espresso documents thoroughly and could not find a working example. Authentication did not seem to have a route nor did registrations toggle_checkin. Could you assist me with this?

Thanks


Josh

  • Support Staff

October 22, 2019 at 1:25 pm

Hi,

A request to un-register a registration would be an example of a PUT or PATCH request:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-writing-data.md#updatingputting

where you would send a request to update the registration’s status (the STS_ID field) to “cancelled” (change to RCN).


setarnv

October 31, 2019 at 6:42 am

How can I register a user?


Josh

  • Support Staff

October 31, 2019 at 7:22 am

Hi,

There are a few plugins that add the ability to add a user:

https://wordpress.org/plugins/wp-rest-user/

https://wordpress.org/plugins/json-api-user/


setarnv

November 1, 2019 at 8:26 am

I’m sorry, I was not clear. Right now I’m getting all the events via API call and I’d like to register a user to an event and possibly mark them as attended to the event.

Is there an API call that can let me register a wordpress user to an event?

Thank you for your previous answers.


Josh

  • Support Staff

November 1, 2019 at 8:40 am

Yes, it’s not clear what your asking because you mentioned “allow users to (un)register for events”. That’s the opposite of registering. Also, generally speaking, a WordPress user is understood as a “WordPress user account”. It sounds like you want to add a registration (not a user account).

What you can do is follow these steps to get started:

1) Review and follow the examples in the documentation:
a) https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-introduction.md
Especially important: Learn how to use the discovery endpoints and Authentication.
b) https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-writing-data.md
2) Create a registration via Event Espresso’s UI in the WordPress dashboard
3) Review the site’s database tables to see everything that was just written to the database. You’ll note that Event Espresso tables have an _esp_ prefix. Also note that an attendee custom post type is also written to the _posts table, and specific entities within event related tables need to be updated when a registration is added. For example, a ticket’s sold count needs to be incremented when an approved registration is added.
4) Learn how to read/GET the related registration data using the REST API:
https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-reading-data.md
https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-GET-including-specific-fields-and-related-entities-in-results.md
Here you’ll note how to do GET requests for registration-related data, which you’ll use much of the same syntax for POSTing data.
5) Once you’ve gotten this far, you can start putting together REST API requests to write to the database


setarnv

November 1, 2019 at 9:11 am

That is my mistake. I want to register a user to an event.
I am fairly familiar with the endpoints and authentication is done with JWT authentication. I cant seem to find a way to register via the dashboard but I am able to register with firstname, lastname, and email via the site on a page that has the events shown using [ESPRESSO_EVENTS]. I am also a bit familiar with the database and I have already made some GET/POSTS request with Espresso events so that shouldnt be a problem.

What would be the next step?
Thank you for your swift reply!


Josh

  • Support Staff

November 1, 2019 at 10:29 am

Step 1 from above would be your first step if you haven’t yet reviewed the REST API documentation for Event Espresso yet.


setarnv

November 1, 2019 at 10:38 am

I have reviewed the documentation before yes 🙂


Josh

  • Support Staff

November 1, 2019 at 11:33 am

So after you make a test registration, you’ll look into the database and check the tables including esp_registration, esp_answer, esp_transaction, esp_datetime, esp_ticket, and so on. There you’ll see exactly what data was added and updated for that registration. Then you can follow the example in the documentation for POSTing an answer:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-writing-data.md#creatingposting

Then, similar to the above example, you’ll add more POST requests to the other endpoints related to the other tables.

The support post ‘Register user via API call’ 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.

Get online help with the WP User Integration add-on by creating a support topic in this forum. Offer member pricing with the WP User Integration. WP User Integration documentation.

Status: closed

Updated by  Josh 1 year, 2 months ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!