- This topic has 1 reply, 2 voices, and was last updated 4 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › How to automatically login after registration using API
Tagged: api, Registration
I would like to know how to log in a user automatically after registering them via the API
I use curl from a PHP script in the WordPress site theme to register the user, then I want them to be logged in so I can direct them into the member portions of the site
Here is the code I am using to perform the registration. The registration is working correctly. I would like to log the user in after the registration completes successfully
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, get_site_url() . “/”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, ‘curl’);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_arr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
}
curl_close($ch);
$result = json_decode($response, true);
if ($result[‘result’] == ‘success’) {
//log in the user
}
Hi,
The API related questions are beyond the scope of the free support (since a developer needs to investigate your particular use case). This needs to be handled using a paid support ticket.
https://simple-membership-plugin.com/paid-support-simple-membership-plugin/
Thank you.