# Imported Discourse -\> Wordpress Users Get Error

**URL:** https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903
**Category:** WordPress
**Created:** [October 6, 2018, 8:33pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903 "2018-10-06T20:33:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [October 6, 2018, 8:33pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/1 "2018-10-06T20:33:00Z")

</div>

I’m working on setting up SSO on my community at [https://community.productivityguild.com](https://community.productivityguild.com) where my Wordpress site at [https://productivityguild.com](https://productivityguild.com) is set as the SSO provider. Everything appears to be working correctly for new user signups and for users who sign up for a Wordpress account manually. However, for imported users, I’m getting this error in the Discourse logs:

```plaintext
Verbose SSO log: Record was invalid: User 
{:primary_email=>"has already been taken"}

Attributes:
{"admin"=>false, "moderator"=>false, "locale"=>nil, "name"=>"justin_test", "title"=>nil, "username"=>"justin_test1"}

SSO Diagnostics:
add_groups: 
admin: 
moderator: 
avatar_force_update: false
avatar_url: https://secure.gravatar.com/avatar/da5a673780dc8ac88d30098e04153730?s=96&d=404&r=g
bio: 
card_background_url: 
email: dirose.justin+test@gmail.com
external_id: 1216
groups: 
locale: 
locale_force_update: 
name: justin_test
nonce: d13a1196fbea800db55411422de0721f
profile_background_url: 
remove_groups: 
require_activation: true
return_sso_url: 
suppress_welcome_message: 
title: 
username: justin_test
website: 

```

It’s true because the account already exists on the Discourse site. However from the looks of the error it is passing a new username over to Discourse with a 1 appended to it.

Wordpress debug logs don’t show anything out of the ordinary either. I’m not quite sure where to go with this one. @simon or others, have any suggestions?

---

<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: [October 6, 2018, 8:41pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/2 "2018-10-06T20:41:35Z")

</div>

I think you are running into a problem that’s due to some recent changes to the [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) code. If a user’s email address is not validated, Discourse is no longer matching existing users based on their email address. This is a good change, but is going to cause issues for some sites. I’ll look into finding a workaround for the issue.

To confirm that this is the problem, do you know if the users who are successfully logging into Discourse are having to respond to the Discourse activation email before they can first login?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [October 6, 2018, 8:44pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/3 "2018-10-06T20:44:49Z")

</div>

> [@simon](#):
>
> To confirm that this is the problem, do you know if the users who are successfully logging into Discourse are having to respond to the Discourse activation email before they can first login?

I just created a second test user through the SSO process. No, I was not prompted to respond to the activation email before first login.

---

<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: [October 6, 2018, 8:55pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/4 "2018-10-06T20:55:12Z")

</div>

> [@justin](#):
>
> No, I was not prompted to respond to the activation email before first login.

If you look at the SSO logs on Discourse for your recent login is the `require_activation` parameter set to `false`? I’m fairly sure the issue with the SSO login attempt in your initial post is that `require_activation` is being set to `true`. Whether it’s set to `true` or `false` will depend on how a user has registered on your WordPress site. Unless users are registering through the default WordPress login system, `require_activation` will be set to `true`. Maybe this is the problem with your imported users?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [October 6, 2018, 8:58pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/5 "2018-10-06T20:58:18Z")

</div>

> [@simon](#):
>
> If you look at the SSO logs on Discourse for your recent login is the `require_activation` parameter set to `false` ? I’

Yes this is the case.

It does appear that in the failed login attempts `require_activation` is set to `true`.

Is there a way to work around this?

---

<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: [October 6, 2018, 9:06pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/6 "2018-10-06T21:06:25Z")

</div>

> [@justin](#):
>
> Is there a way to work around this?

Here’s a temporary solution that will be safe for your case **if** you are certain that the email addresses of your imported users are valid, **and** you continue to use the default WordPress login system for your new users. If you ever switch to using a front-end login system that doesn’t validate emails, you must be sure to remove this code. Try copying this function into your theme’s `functions.php` file:

```plaintext
add_filter( 'discourse_email_verification', 'wpdc_custom_email_verification' );
function wpdc_custom_email_verification() {

    return false;
}

```

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [October 6, 2018, 9:10pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/7 "2018-10-06T21:10:05Z")

</div>

> [@simon](#):
>
> Here’s a temporary solution that will be safe for your case **if** you are certain that the email addresses of your imported users are valid, **and** you continue to use the default WordPress login system for your new users. If you ever switch to using a front-end login system that doesn’t validate emails, you must be sure to remove this code.

I think this did the trick!

Thanks a bunch, Simon.

---

<div class="post-metadata">

### Author: ![jesselperry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jesselperry/32/119501_2.png) [@jesselperry](https://meta.discourse.org/u/jesselperry)
#### Post date: [October 11, 2018, 4:53pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/8 "2018-10-11T16:53:32Z")

</div>

THANK YOU - this was my issue and this fixed it

---

<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: [November 10, 2018, 5:00pm UTC](https://meta.discourse.org/t/imported-discourse-wordpress-users-get-error/98903/9 "2018-11-10T17:00:24Z")

</div>

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