By using Actions within the PRO plugin, you can very easily capture a newly registered user on your site and send their details to any API you like.
You simply need to setup the endpoint that you want to send the user details to, select User – New user Registered as the action and then insert the users data within the endpoint. It looks something like the below:
We use the Tokens that look like (action:data:some_data_to_get) to grab the users details. Here are what the values look like that are available:
array ( 'data' => array( 'user_login' => 'Test Username', 'user_email' => 'email@example.com', 'user_pass' => 'xxxxxxxxxx', 'meta' => array( 'custom_value1' => 'stuff', 'custom_value2' => 'some data', 'another_one' => 'something', ) ) )
To get the ‘custom_value1’ value within this array, we would use a token like this: (action:data:meta:custom_value1) which would return the value of ‘stuff’.
You can see these values by setting up your endpoint as above and then registering a new user. You then visit the Actions Log page at WPGetAPI > Actions Log within your admin. There you will see all the data that is available to send to the API.
Old method to call API on User Registration
Below is the old way to send user registration details to an API. This method is still available and still works, but is a little more cumbersome to set up. We are leaving this here as an alternative method.
This feature uses the default WordPress hook –
user_register – which makes this feature available to every plugin or theme that uses the standard WordPress registration method, which should be 99% of them. Even if your plugin or theme uses a custom looking registration form, or even social login/registration, chances are they are using this default WordPress registration hook.
It also obviously works for the default WordPress registration page located at www.yoursite.com/wp-login.php?action=register
How to use it
This is as simple as setting an attribute within your endpoint settings page and then using Tokens to grab the email and username fields, or to grab any custom fields that have been added to your registration form.
Let’s look at how to set it up: