Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Sign On between Wordpress and a Custom Website

I am building an e-commerce website with WordPress. And I have list of emails and names. My website need to be accessed only by people with those emails when they click on a link on another custom website which is not built with WordPress.

What I want is, when clients click the link to my WordPress website, they automatically get logged in in WordPress and they start right away shopping.

Please how can I achieve this?

The solution I thought of is to pass email as parameters in the URL. Then in WordPress I will create a new user with the passed email and I will log the user in then I will redirect the user to the home page.

Is this a good solution?

like image 203
Mohammed W Avatar asked Jan 28 '23 02:01

Mohammed W


1 Answers

Try this, called Single Sign On or SSO. You would essentially be bypassing WordPress' authentication methods and use those from a 3rd party. WordPress needs a local user of some kind for normal operations to work (the user_can() function for example.)

So the general gist would be something like this - Send any request for authentication to a 3rd party who will yay or nay and return some data about the user - if yay, check if there is a WordPress user that represents the authenticated user. If not, create one and add any meta data you might need from the third party. - these WordPress users are like placeholders and every time you successfully authenticate, you update the meta data of the WordPress user to keep things in sync.

This is how OneLogin does it and you can poke around their WordPress plugin to get a sense of how it works.

https://wordpress.org/plugins/onelogin-saml-sso/

Or You can refer this also.

http://carlofontanos.com/auto-login-to-wordpress-from-another-website/

like image 158
PPL Avatar answered Feb 09 '23 00:02

PPL