Wordpress SSO AND Patreon Login

Okay, I have found a workaround, which is “fixes” the issue with Patreon login. Please find instructions below. :slight_smile:

You will need:

  • Any plugin, which provides a shortcode to display login form (I have WooCommerce installed on my site, so I used [woocommerce_my_account] shortcode, which does exactly this for non-logged in users).
  • Members plugin, which provides [members_logged_in] and [members_not_logged_in] shortcodes to hide/show content depending on if user is logged in or not. You can use any other plugin which provides similar shortcodes functionality.
  • Shortcode Redirect plugin.

The idea is to create a special page, which displays a login form (and Patreon login button) for non-logged in users. And if user is logged in, then it should redirect to 'https://community.morevnaproject.org/session/sso?return_path=%2F` url.
(Obviously, you will want to replace “community.morevnaproject.org” with your own domain).

My special login page has the following content:

[members_not_logged_in]
   [woocommerce_my_account]
   [patreon_login_button]
[/members_not_logged_in]
[members_logged_in]
   [redirect url='https://community.morevnaproject.org/session/sso?return_path=%2F' sec='0']
[/members_logged_in]

(you can see it in action here - https://morevnaproject.org/log-in-discourse/)

Then, all you need is to configure WP-Discourse plugin to use that page for SSO -

When user clicks “Log In” button in Discourse, he is redirected to my special Wordpress page. As the user is not logged in, it displays login form. If user clicks “Log in wiht Patreon” button, then he is redirected to Patreon for authorization. After successful authorization he is redirected back to my special page. SInce user is now logged in, then “redirect” shortcode is activated:

[redirect url='https://community.morevnaproject.org/session/sso?return_path=%2F' sec='0']

…and user successfully redirected back to discourse forums.

The session/sso?return_path=%2F part at the end of URL is required, otherwise Discourse will not recognizes user as logged in after redirect.

That’s it! I hope this will help other users, who want to have Wordpress SSO with Patreon Login on their website. :slight_smile:

2 Likes