# Get Discourse to recognize accounts verified in Wordpress (and WooCommerce) for SSO

**URL:** https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535
**Category:** WordPress
**Created:** [2 januari 2020 om 06:51 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535 "2020-01-02T06:51:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [2 januari 2020 om 06:51 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535/1 "2020-01-02T06:51:05Z")

</div>

Continuing the discussion from [How to turn off Discourse email verification?](https://meta.discourse.org/t/how-to-turn-off-discourse-email-verification/75365/4):

> [@How to turn off Discourse email verification?](https://meta.discourse.org/t/how-to-turn-off-discourse-email-verification/75365/4):
>
> The [WP Discourse](https://github.com/discourse/wp-discourse) plugin hooks into the WordPress registration process and verifies that the email sent by `wp_new_user_notification` was responded to.

Discourse is not recognizing our verified accounts. Here’s some context around our current site setup:

I’m using the [WP Discourse](https://github.com/discourse/wp-discourse) Plugin with WP as SSO Provider

> **Current SSO Settings \<img\>**
>
> ![image](https://global.discourse-cdn.com/meta/original/3X/4/3/4363f22d11d55bbd722dc0814858fa20eaf22b4d.jpeg)

I’m currently using WooCommerce (WC) to manage new user registrations, here: [https://pickleballist.com/my-account](https://pickleballist.com/my-account)

I’m using a plugin called [Booster for WC](https://wordpress.org/plugins/woocommerce-jetpack/), which adds additional functionality to WC, including the ability to require email verification before a user can access their account.

> **Plugin Options \<img\>**
>
> ![image](https://global.discourse-cdn.com/meta/original/3X/3/9/392af563e78aa944ed057a9e77bc49c67256db02.png)

> **Verification Email received \<img\>**
>
> ![image](https://global.discourse-cdn.com/meta/original/3X/e/b/eb0200b743330b4ec000796f301ac07e77c2396b.png)

After the user clicks the link in their Account Activation email, they are taken to their /my-account/ page, in Wordpress. If a person tries to login with their registration credentials without clicking the verification link, they are told that their account first needs to be verified, and they get a link they can click to “resend verification email”

If you visit the “Users” page in the Admin console, you can easily see whose accounts have been verified and which ones have not.

> **User Accounts with Verification depiction \<img\>**
>
> ![Monosnap 2020-01-01 21-58-12](https://global.discourse-cdn.com/meta/original/3X/3/e/3ec3b0d3bcdd51b72df5428d1ceaa36753f9df12.jpeg)

Unfortunately, after this user has verified their email and then tries to visit our forums over at [https://forums.pickleballist.com](https://forums.pickleballist.com), they are not automagically logged in. 😞 But the worst part is that when they click the “Login” button on the forums, they are required to check their email and click the Discourse “Confirm your new account” email link.

Is there a way to get Discourse to check who is actually verified based on the metadata that is being received from WooCommerce?

I’m guessing this “Email Verification Module” is not touching `wp_new_user_notification` or else Discourse would see that, right? Can we have Discourse look for some other hook?

Looking forward to any insight here!

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [2 januari 2020 om 17:36 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535/2 "2020-01-02T17:36:29Z")

</div>

@simon I just noticed your comment here:

> [@Auto activated accounts for WP Discourse SSO?](https://meta.discourse.org/t/auto-activated-accounts-for-wp-discourse-sso/90272/6):
>
> As long as users are not automatically logged in before responding to the password reset email, you can use this function. It will work without any changes: add\_filter( 'discourse\_email\_verification', 'wpdc\_custom\_disable\_email\_verification' ); function wpdc\_custom\_disable\_email\_verification() { return false; }

Would using that ⬆︎ code snippet be the solution to what I’m trying to accomplish?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2 januari 2020 om 18:12 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535/3 "2020-01-02T18:12:37Z")

</div>

> [@jord8on](#):
>
> Would using that ⬆︎ code snippet be the solution to what I’m trying to accomplish?

As long as the Booster for WC plugin prevents users from being able to login to WordPress before they have verified their email address, that code will be safe to use. When added to your theme, or to a plugin, it will allow users to login to your Discourse site without having to re-verify their email address.

> [@jord8on](#):
>
> Is there a way to get Discourse to check who is actually verified based on the metadata that is being received from WooCommerce?

This would also be possible. If you know the name of the metadata key that is being set by Woocommerce and the expected return value for users with verified email addresses, you could add a check for that to the function. Something like this:

```php
add_filter( 'discourse_email_verification', 'wpdc_custom_discourse_email_verification', 10, 2 );
function wpdc_custom_discourse_email_verification( $require_activation, $user_id ) {
    if ( 1 === get_user_meta( $user_id, 'wc_metadata_key', true ) ) {
        $require_activation = false;
    }

    return $require_activation;
}

```

If you are running into any SSO login redirect issues with Woocommerce, you may need to install this plugin on your site: [GitHub - scossar/wp-discourse-woocommerce-support: Integrates the wp-discourse plugin with WooCommerce · GitHub](https://github.com/scossar/wp-discourse-woocommerce-support). Have a look at the plugin’s readme for details about what it does.

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [3 januari 2020 om 23:14 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535/4 "2020-01-03T23:14:05Z")

</div>

That code did the trick! Users now only have to click the WP generated verification link. 🙏 Thank you!

> [@simon](#):
>
> If you are running into any SSO login redirect issues with Woocommerce, you may need to install this plugin on your site: [GitHub - scossar/wp-discourse-woocommerce-support: Integrates the wp-discourse plugin with WooCommerce](https://github.com/scossar/wp-discourse-woocommerce-support). Have a look at the plugin’s readme for details about what it does.

I just added this but when the user clicks the WP generated Verification link, it just takes them to their /my-account page in WP, after they verify. It doesn’t take them back to the Discourse forums. What is the expected behavior here?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [3 januari 2020 om 23:42 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535/5 "2020-01-03T23:42:32Z")

</div>

> [@jord8on](#):
>
> I just added this but when the user clicks the WP generated Verification link, it just takes them to their /my-account page in WP, after they verify. It doesn’t take them back to the Discourse forums. What is the expected behavior here?

I think the verification link is being generated by the Booster for WC plugin. If this is the case, then it’s not something that I’ve tested. The issue that the wp-discourse-woocommerce-support plugin is meant to solve is overriding a login redirect that is set by Woocommerce on every login attempt. I haven’t tested it with Woocommerce recently, but in the past when Woocommerce is installed on a site it prevented non-logged in users from being redirected to Discourse when they attempt to login through WordPress.

The expected bahaviour is that when a user who isn’t logged into WordPress clicks either the login button on Discourse, or an SSO login link that’s been generated below a post that’s been published to Discourse, the user will be taken through the WordPress login process and then redirected to the correct Discourse URL. Let me know if this isn’t working correctly for users who have verified their email address.

It may be possible to get this to work with the verification link your users are clicking, but I think that’s a seperate issue.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [11 februari 2020 om 09:09 UTC](https://meta.discourse.org/t/get-discourse-to-recognize-accounts-verified-in-wordpress-and-woocommerce-for-sso/137535/7 "2020-02-11T09:09:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
