This documentation is only for developers. If you are not a developer with good PHP coding skills then you have no need to read this.
If you want to update a member account using a HTTP GET or POST request then use this documentation.
Enabling the API
WP eMember plugin has an API that allows you to update a member account using a standard HTTP GET or POST request. If you want to use this API then you need to enable it from the settings menu of the plugin first. The following is a screenshot of this section in the settings menu:
It is very important that you do not reveal the Secret Word/API key to anyone else.
Using the API
Once you enable it, you can start to send HTTP request to the following URL to update member accounts remotely or from another software/application:
You need a minimum of 2 pieces of information to send an update request. These are:
- Secret Word/API Key (you specified it in the settings menu of the plugin)
- Member ID (the user whose details you want to update)
Optionally, you can pass the following fields with the request to update the values of those fields for the member’s account in question.
1. Updating Member Account Using HTTP GET request
In order to update a member account via HTTP GET request, use the following format:
Replace the “example.com” and “XX” with the appropriate values.
PHP Code Example:The following is an example of how to construct this URL using PHP:
$secret_key = "6bd39ewe43a7bb"; $member_id= "1"; $first_name= "Jon"; $last_name= "Doe"; $prepared_data = "?secret_key=".$secret_key."&member_id=".$member_id."&first_name=".$first_name."&last_name=". $last_name; $get_url = "http://www.example.com/wp-content/plugins/wp-eMember/api/update.php".$prepared_data; // Execute this GET Request file_get_contents($get_url);
2. Updating Member Account Using HTTP POST request
To update a member account via HTTP POST use the following format:
<form method="post" action="http://www.example.com/wp-content/plugins/wp-eMmeber/api/update.php"> <input type="hidden" name="secret_key" value="XX"> <input type="hidden" name="member_id" value="XX"> <input type="hidden" name="first_name" value="XX"> <input type="hidden" name="last_name" value="XX"> <input type=submit value="Submit Post"> </form>
Replace the “example.com” and “XX” with the appropriate value.
@Chris, The ID value (which can’t be modified by the member from the front-end) is the best reference to use when updating a profile.
You can query the member’s profile using the email address. See the following link:
You will get the ID value from that query.
To update a member’s details, it requests the member_id. Short of looking this up in wp_admin, and manually creating the GET / POST etc, is this value returned via the “create.php” code? Or can it – like other sections – use the customer’s email address?
@Andrea, If you have the secondary level feature enabled, then calling the update function with a “membership_level_id” value will create the following behavior:
1) The current level will be pushed to the secondary level.
2) Then the new level will be assigned as the main membership level for the user.
Is it possible to add an additional (second) membership level through API?
Which field should I use?
@Chris, You configure the subscription duration settings in the membership level. Then when you create a member account using the API, you can specify which membership level this user will go to to.
Can we pass the subscription duration using HTTP?
So far users have asked for the following capability via API:
– Create members
– Update members
– Deactivate members
If you explain exactly what you need, we should be able to add an option for that.
There doesn’t seem to be a query API. So how could one “query all the current members via the API?”?
@Graycloud, You could call this API in a loop for each member from your application.
is there a way to query all the current members via the API?
@Vikto, Yes you can update the member’s password too. Send the value in a field named ‘password’ to update it.
Is it possible to update password through this update API?
I’m trying to connect it with our client management platform.