# Disable account activation email with SSO

**URL:** https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859
**Category:** WordPress
**Created:** [12 Septiembre, 2017 02:03 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859 "2017-09-12T02:03:58Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![outergain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outergain/32/101144_2.png) [@outergain](https://meta.discourse.org/u/outergain)
#### Post date: [12 Septiembre, 2017 02:03 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/1 "2017-09-12T02:03:58Z")

</div>

I’ve been using Discourse on my own Linode for awhile. That install tanked today, and so I just went with the paid Discourse service. However, now when my WordPress users try and access the forum for the first time, they’re given this activation email step that we didn’t have to do before. Anyway to disable this? Thanks!

---

<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: [12 Septiembre, 2017 02:06 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/2 "2017-09-12T02:06:36Z")

</div>

> [@outergain](#):
>
> now when my WordPress users try and access the forum for the first time, they’re given this activation email step that we didn’t have to do before.

Are these new users, or users who already existed on your WordPress site?

---

<div class="post-metadata">

### Author: ![outergain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outergain/32/101144_2.png) [@outergain](https://meta.discourse.org/u/outergain)
#### Post date: [12 Septiembre, 2017 02:47 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/3 "2017-09-12T02:47:59Z")

</div>

Users who already existed and new - they both act the same.

---

<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: [12 Septiembre, 2017 02:53 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/4 "2017-09-12T02:53:29Z")

</div>

Are you using the [WP Discourse](https://github.com/discourse/wp-discourse) plugin? If so, did you have in installed when the users were first created. The way it is supposed to work is that when a user is first created with the [WP Discourse](https://github.com/discourse/wp-discourse) plugin enabled, their email address is flagged as being unverified. If the users are registered through the default WordPress registration process, that flag is removed and they are able to login to Discourse without having to confirm their email. If you are using a custom registration process, then users will have to verify their email address.

It is possible to override that flag, but I"m curious as to why it’s being applied to existing users.

---

<div class="post-metadata">

### Author: ![outergain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outergain/32/101144_2.png) [@outergain](https://meta.discourse.org/u/outergain)
#### Post date: [12 Septiembre, 2017 03:22 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/5 "2017-09-12T03:22:33Z")

</div>

Yes, I’m using the [WP Discourse](https://github.com/discourse/wp-discourse) plugin.

The only difference is this: Yesterday I was on a self hosted installation of Discourse. It crashed today. So I just spun up a paid version with [Discourse.org](http://Discourse.org). Now this is happening (and I updated the keys, etc)

---

<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: [12 Septiembre, 2017 03:31 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/6 "2017-09-12T03:31:31Z")

</div>

It’s odd that it’s being applied to existing users. The easiest way to disable it is to hook into the `discourse_email_verification` filter. It’s applied before the SSO parameters are sent to Discourse.

Adding something like this to your theme’s `functions.php` file should work. Ideally, you should only be doing this if you have verified the email address in some way through WordPress.

```plaintext
// Replace 'my_prefix' with your site prefix.

add_filter( 'discourse_email_verification', 'my_prefix_discourse_email_verification', 10, 2 );
function my_prefix_discourse_email_verification( $require_activation, $user_id ) {
    // Check that the user has a valid email address, or just return false for all users.

    return false;
}

```

---

<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: [12 Septiembre, 2017 03:42 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/7 "2017-09-12T03:42:31Z")

</div>

For existing users, I’d be curious to know what

`get_user_meta( $user_id, 'discourse_email_not_verified', true )`

is returning. If it’s not returning `1`, then the issue with existing users is probably something that’s happening on the Discourse end. For new users, unless you are using the default WordPress login, having the account activation email sent by Discourse is the expected behaviour.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [12 Septiembre, 2017 04:05 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/8 "2017-09-12T04:05:44Z")

</div>

Did you restore your old discourse site to the new one or did you just start a new discourse?

---

<div class="post-metadata">

### Author: ![outergain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outergain/32/101144_2.png) [@outergain](https://meta.discourse.org/u/outergain)
#### Post date: [12 Septiembre, 2017 17:11 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/9 "2017-09-12T17:11:49Z")

</div>

Brand new one. This is the 5th discourse instance I’ve had setup, and none of them have ever done this until now. It’s weird.

---

<div class="post-metadata">

### Author: ![outergain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outergain/32/101144_2.png) [@outergain](https://meta.discourse.org/u/outergain)
#### Post date: [12 Septiembre, 2017 17:20 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/10 "2017-09-12T17:20:36Z")

</div>

Thanks @simon - dumb question, but what exactly is the “site prefix.”

---

<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: [12 Septiembre, 2017 17:39 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/11 "2017-09-12T17:39:03Z")

</div>

> [@Create user automatically in Discourse when they sign up in Wordpress?](https://meta.discourse.org/t/create-user-automatically-in-discourse-when-they-sign-up-in-wordpress/58494/19):
>
> The site prefix is just a unique key that you use to prefix functions on your site. It’s used to avoid naming collisions when PHP namespaces aren’t being used. You can set it to anything that’s allowable in a PHP function name., for example matt\_chm\_discourse\_email\_verification.

---

<div class="post-metadata">

### Author: ![outergain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outergain/32/101144_2.png) [@outergain](https://meta.discourse.org/u/outergain)
#### Post date: [12 Septiembre, 2017 18:07 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/12 "2017-09-12T18:07:38Z")

</div>

You are the man! Everything works - thanks a million.

---

<div class="post-metadata">

### Author: ![Francois\_Douville](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/francois_douville/32/94221_2.png) [@Francois\_Douville](https://meta.discourse.org/u/Francois_Douville)
#### Post date: [6 Junio, 2018 20:23 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/13 "2018-06-06T20:23:48Z")

</div>

My WP is SSO provider. I use the plugin Activemember360 with a custom registration page. When they register, they only type name and email. Their password is send to their email. So that’s a way to verify their email?

After that, they also have to verify their email with Discourse. It’s not useful.

> [@simon](#):
>
> Adding something like this to your theme’s `functions.php` file should work. Ideally, you should only be doing this if you have verified the email address in some way through WordPress.
> 
> ```plaintext
> // Replace 'my_prefix' with your site prefix.
> 
> add_filter( 'discourse_email_verification', 'my_prefix_discourse_email_verification', 10, 2 );
> function my_prefix_discourse_email_verification( $require_activation, $user_id ) {
> // Check that the user has a valid email address, or just return false for all users.
> 
> return false;
> }
> 
> ```

Is this code is what I need to disable account activation?

If yes, I don’t know how to do this. Could you help me?

Thanks

---

<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: [7 Junio, 2018 17:23 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/14 "2018-06-07T17:23:35Z")

</div>

> [@Francois\_Douville](#):
>
> Is this code is what I need to disable account activation?
> 
> If yes, I don’t know how to do this. Could you help me?

Yes, that code will disable the account activation email for all users. It sounds as though that is safe to do for your case.

Here is a simplified version of the code that will disable the account activation email for all users:

```php
add_filter( 'discourse_email_verification', 'wpdc_custom_disable_email_verification' );
function wpdc_custom_disable_email_verification() {

	return false;
}

```

This code needs to be added to either a WordPress plugin, or to your theme’s `functions.php` file. Adding it to the `functions.php` file is the easiest way to do it. If you are editing that file on a live site, you should access the site’s file system through its cPanel, save a backup of `functions.php` and then copy and paste the code into the original file. If everything works as expected, delete the backup file.

---

<div class="post-metadata">

### Author: ![Francois\_Douville](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/francois_douville/32/94221_2.png) [@Francois\_Douville](https://meta.discourse.org/u/Francois_Douville)
#### Post date: [7 Junio, 2018 17:36 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/15 "2018-06-07T17:36:27Z")

</div>

Thanks!

No need to change the prefix site like you said in the older code?

---

<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: [7 Junio, 2018 17:46 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/16 "2018-06-07T17:46:23Z")

</div>

> [@Francois\_Douville](#):
>
> No need to change the prefix site like you said in the older code?

Using a prefix for custom function names is just a simple way to avoid naming collisions. If there are two functions in your WordPress code with the same name, your site will crash. As long as you don’t have another function named `wpdc_custom_disable_email_verification` you’ll be fine to keep the name as it is.

---

<div class="post-metadata">

### Author: ![Francois\_Douville](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/francois_douville/32/94221_2.png) [@Francois\_Douville](https://meta.discourse.org/u/Francois_Douville)
#### Post date: [7 Junio, 2018 18:49 UTC](https://meta.discourse.org/t/disable-account-activation-email-with-sso/69859/17 "2018-06-07T18:49:34Z")

</div>

Thanks, it works perfectly!
