- There are following methods available: register, get_avatar, get_userinfo, retrieve_password, validate_auth_cookie, generate_auth_cookie, get_currentuserinfo, get_user_meta, update_user_meta, delete_user_meta, xprofile, xprofile_update, fb_connect
- nonce can be created by calling if you are registering user. http://localhost/api/get_nonce/?controller=user&method=register
- You can then use ‘nonce’ value to register user.
- Always use POST method and not GET method to submit data, following url examples of GET method are only for demonstration purposes.
Method: info
http://localhost/api/user/info/
This returns plugin version.
Method: register
http://localhost/api/user/register/?username=john&email=john@domain.com&nonce=8bdfeb4e16&display_name=John¬ify=both
To register user & get valid cookie for 100 seconds: http://localhost/api/user/register/?username=john&email=john@domain.com&display_name=John¬ify=both&seconds=100
Optional fields: ‘user_pass’, ‘user_nicename’, ‘user_url’, ‘nickname’, ‘first_name’, ‘last_name’, ‘description’, ‘rich_editing’, ‘user_registered’, ‘jabber’, ‘aim’, ‘yim’, ‘comment_shortcuts’, ‘admin_color’, ‘use_ssl’, ‘show_admin_bar_front’.
Please make sure you provide valid values that these fields expect in correct format.
To disbale registration email notification to user:
http://localhost/api/user/register/?username=john&email=john@domain.com&nonce=8bdfeb4e16&display_name=John¬ify=no
To register with user provided password:
http://localhost/api/user/register/?username=john&email=john@domain.com&nonce=8bdfeb4e16&display_name=John¬ify=both&user_pass=YOUR-PASSWORD
To add custom fields for user profile, send ‘custom_fields’ named associative array, populated with standard ‘meta_key’ as index and ‘meta_value’ as its value. For example, you need to add address and phone for any user, populate custom_fields[address] index with address value and custom_fields[phone] with hpone value.
You can add any number of custom fields. These are stored as meta_key and meta_value in user_meta WordPress table. You can access these values in WordPress using get_user_meta() fucntion.
You can also get these values with get_user_meta endpoint, see below this endpoint documentation.
Method: fb_connect
It needs valid ‘access_token’ var.
http://localhost/api/user/fb_connect/?access_token=CAACEdEose0cBADLKmcHWOZCnW4RGU8emG
Provide valid access_token with email extended permission. To generate test access_token, try this tool https://developers.facebook.com/tools/explorer/ and select the app from above drop down that you want to get access_token (You must have joined that app already with email permission to generate access_token) for and then select email from the fields. By default, only ‘id’ and ‘name’ are added but you need to include ’email’ for user identification.
You will have to first allow extended permission for email in the app joining screen. Please note that above tool is only for testing, you generate valid access_token using the Graph API in your app. You should know Facebook Graph API to use this endpoint.
Method: validate_auth_cookie
It needs ‘cookie’ var.
http://localhost/api/user/validate_auth_cookie/?cookie=admin|43089754375034fjwfn39u8
Method: generate_auth_cookie
It needs username , password vars. seconds is optional.
First get the nonce: http://localhost/api/get_nonce/?controller=user&method=generate_auth_cookie
Then generate cookie: http://localhost/api/user/generate_auth_cookie/?username=john&password=PASSWORD-HERE
Optional ‘seconds’ var. It provided, generated cookie will be valid for that many seconds, otherwise default is for 14 days.
generate cookie for 1 minute: http://localhost/api/user/generate_auth_cookie/?username=john&password=PASSWORD-HERE&seconds=60
60 means 1 minute.
Method: delete_user_meta
It needs ‘cookie’ and ‘meta_key’ var and ‘meta_value’ to delete.
http://localhost/api/user/delete_user_meta/?cookie=COOKIE-HERE&meta_key=KEY-HERE&meta_value=VALUE-HERE
Method: update_user_meta
It needs ‘cookie’ and ‘meta_key’ var and ‘meta_value’ to update. You must include a ‘meta_value’ var in your request. If you have multiple values for any meta_key, you must send it as an array meta_value[] in POST method.
http://localhost/api/user/update_user_meta/?cookie=COOKIE-HERE&meta_key=KEY-HERE&meta_value=VALUE-HERE
Method: update_user_meta_vars
It needs ‘cookie’ and any user meta variables. This endpoint allows you cut http requests if you have to add/update more than one user_meta field at a time.
http://localhost/api/user/update_user_meta_vars/
In the above endpoint use custom_fields[‘website’]=domain.com, custom_fields[‘city’]=NYC, custom_fields[‘country’]=USA as meta_key for WordPress user_meta values using POST method.
If you have multiple values for any variable, you must send it as an array i.e. variable_name[] in POST method. For instance, you have skills variable with multiple values, you will send a custom_fields[‘skills’][] array with its values using POST method.
Method: get_user_meta
It needs ‘user_id’. ‘meta_key’ var is optional.
http://localhost/api/user/get_user_meta/?cookie=COOKIE-HERE&meta_key=KEY-HERE
Method: xprofile
It needs ‘user_id’ and any profile ‘field’ var.
http://localhost/api/user/xprofile/?user_id=USERID-HERE&field=FIELD-LABEL-HERE
Method: xprofile_update
It needs ‘cookie’ and any profile ‘field’ var and ‘value’.
http://localhost/api/user/xprofile_update/?cookie=COOKIE-HERE&exact-xprofile-field-label=value
http://localhost/api/user/xprofile_update/?cookie=COOKIE-HERE&field=value&field2=value&multi-value-field=value1,value2,value3
Please make sure you provide ending comma for all those fields which have multiple values. e.g. If ‘skills’ xProfile field has multiple values, pass them like http://localhost/api/user/xprofile_update/?cookie=COOKIE-HERE&skills=PHP,MySQL, or &skills=PHP, make sure you always pass ending comma for multi-select fields to be added in array format.
Method: retrieve_password
It needs user_login var.
http://localhost/api/user/retrieve_password/?user_login=john
Method: get_avatar
It needs user_id var.
http://localhost/api/user/get_avatar/?user_id=1
Method: get_userinfo
It needs user_id var.
http://localhost/api/user/get_userinfo/?user_id=1
Method: post_comment
It needs ‘cookie’, ‘post_id’, ‘content’ vars. ‘comment_status’ is optional.
http://localhost/api/user/post_comment/?cookie=COOKIE-HERE&post_id=ID&content=Comment contents here&comment_status=1
Comment content is sanitized with wp_filter_post_kses() before being saved, and the comment is inserted via wp_new_comment() so normal WordPress comment moderation, flood checks, and spam filtering (e.g. Akismet) still apply. ‘comment_status=1’ only auto-approves the comment if the authenticated user has the ‘moderate_comments’ capability (e.g. Editor/Administrator); otherwise the comment falls back to the site’s default moderation rules. ‘comment_status=hold’ (or omitting the param) leaves the comment pending the usual moderation workflow.
For additional endpoints, pro version JSON API User Plus plugin details check here https://www.parorrey.com/solutions/json-api-user-plus/