menu

Questions & Answers

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?

Comments:
2023-01-19 23:01:07
Using a blogging platform (i.e. what WordPress was designed for) for e-commerce (i.e. NOT what WordPress was designed for) is the wrong thing to do. WordPress isn't even that great as a blog let alone a general-purpose CMS system. Gotta use the right tool for the job first before talking about implementing a SSO solution.
Answers(1) :

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/

Comments:
2023-01-19 23:01:07
You rock, you are a life saver, this is exactly what I was looking for, THANK YOU