Skip to content

Using WP-API and Hello.js to create seamless login and registration via social channels

License

Notifications You must be signed in to change notification settings

royboy789/wp-api-social-login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WP-API SOCIAL LOGIN

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

API SETUP

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.

USAGE

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 }

LOGIN ENDPOINT

/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 - required
  • user_email from API or injected by user - optional

REGISTRATION ENDPOINT

also handles login post register
/social_registration - us this to register and login a new user.

Data Parameneters

  • social_id from API - required
  • user_email from API or user - required
  • first_name - optional
  • last_name - optional
  • nickname - or WP user nicename optional
  • description - optional

SHORTCODE

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)

FULL SHORTCODE EXAMPLE

[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"]

About

Using WP-API and Hello.js to create seamless login and registration via social channels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published