SSO with Wordpress and Discourse as Provider login Flow and logic
BishopV has successfully set up a single sign-on (SSO) system with Discourse as the provider and Wordpress as the client, allowing users to log in to Wordpress using their Discourse credentials. The current sign-in flow is:
Login at Wordpress > select login with Discourse > Discourse login page > logged in > redirect back to Wordpress website.
BishopV has two questions to further customize the login flow:
How to set up a system where users can log in to Discourse and be automatically logged in to Wordpress in the background?
How to disable all original Wordpress login methods and only allow Discourse login?
To achieve the first requirement, a custom login link can be added to the Discourse forum, which redirects users to Wordpress and then back to Discourse after logging in. The link should include the discourse_sso=1 query parameter and the redirect_to parameter set to the desired URL.
To disable original Wordpress login methods, the /wp-login.php page can be put behind a password known only to Wordpress site admins. However, this approach requires caution to avoid locking oneself out of Wordpress.
Million thanks @simon was assisted me to setting this , finally i can see [ Login with Discourse ] at my wordpress page. now i need clear my mind and figure it out the logic and login flow to more convenient my member go to wordpress make payment .
Now My Page Sign in flow like this
Login at wordpress > select login in with discourse > discourse login page > logged in > redirect back to wordpress website .
im already done setting when member Login at wordpress using discourse login but redirect back to wordpress , but how about i want another setting when they Login at discourse using discourse login but redirect back to discourse but backend will automatic logged in at wordpress website too ?
Disable all my wordpress original login method only discourse login method.
You could add a login link to your Discourse forum similar to this:
<a href="http://example.com/?discourse_sso=1&redirect_to=http://discourse.example.com">Login to WordPress and redirect back to Discourse</a>
The link should point to the base URL of your WordPress site. You need to set the discourse_sso=1 query parameter on the URL. The redirect_to parameter should be set to the URL you want to redirect users to.
It is possible to redirect users either to your WordPress site, or to Discourse with the redirect. I think that for most cases, it would be more useful to redirect users to the WordPress site instead of Discourse. For example:
<a href="http://example.com/?discourse_sso=1&redirect_to=http://example.com/shop">Login to WordPress from a Discourse post</a>
This could be done, but you will need to be careful about not locking yourself out of WordPress if anything goes wrong. A possible approach would be to put your WordPress /wp-login.php page behind a password that is only know to your WordPress site’s admins.