We can do many awesome things with WP-API, when building CodeCavalry we needed a way to get people signed up logged in using social networks. While trying some existing plugins were not happy with the outcome and how the flow worked with our application. We created the start to a social login utilizing WP-API to more seamlessly integrate the login and registration.
This is v2 of our routes and plugin that includes a new table since some social API's don't respond with information you need to check if a user exists or create a user.
Supports GitHub Updater
You will need to go to Settings > Social API to configure the API's you want to use. As of now we are only supporting Facbeook, Twitter, and GitHub.
Do you want us to support more? Go to hellojs and create an issue in this GitHub repo with any supported social network and we will add it in.
Creation of 2 endpoints for WP-API each accepts a data object array, make sure you are passing in an object named data:
var data = { user_id: XXXXXXX, user_email: XXXX@YYY.com }
/social_login
- use this to login an existing user, will do a check if user exists and return WP Error if no user found or insufficient data
Data Paramenters
social_id
from API - requireduser_email
from API or injected by user - optional
also handles login post register
/social_registration
- us this to register and login a new user.
Data Parameneters
social_id
from API - requireduser_email
from API or user - requiredfirst_name
- optionallast_name
- optionalnickname
- or WP user nicename optionaldescription
- optional
Shortcode generates a form for your users -
[social_login]
Shortcode Attributes
- nickname -
true/false
- include nickname field (default: false) - nickname_place_holder -
string
- placeholder for nickname field (default: nickname) - first_name -
true/false
- first name field (default: false) - first_name_placeholder -
string
- placeholder for the first name field (default: First Name) - last_name -
true/false
- last name field (default: false) - last_name_placeholder -
string
- placeholder for the last name field (default: Last Name) - submit_prefix -
string
- for submit buttons (default: Login with) - networks -
comma seperated string
- networks you want to offer (default:facebook,twitter,github) - social_action -
login/register
- used to identify if this is a login form or signup form (default:login) - redirect -
url
- redirect user after sign in or register (default:current url)
[social_login nickname="true" nickname_placeholder="Custom Username" first_name="true" first_name_placeholder="First Name" last_name="true" last_name_placeholder="Last Name" submit_prefix="Register with" networks="facebook,twitter" social_action="register" redirect="/new-page"]