# Welcome PM is sometimes sent twice

**URL:** https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419
**Category:** Bug
**Created:** [Janeiro 26, 2017, 8:37pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419 "2017-01-26T20:37:57Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 8:37pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/1 "2017-01-26T20:37:58Z")

</div>

I’ve been noticing this a fair bit lately:

 ![](https://global.discourse-cdn.com/meta/original/3X/5/7/57e3901b8e90e841e45fff973f07bdf3a9933356.png)

It doesn’t happen every time, but it’s not uncommon. It’s also not new – I first noticed it many months ago. I have customised the text content via the AdminCP but have done nothing else that I’m aware of that could cause this.

Do other people have this issue? It’s not a great first impression.

What further info is required in order to investigate?

---

<div class="post-metadata">

### Author: ![David\_Collantes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david_collantes/32/87919_2.png) [@David\_Collantes](https://meta.discourse.org/u/David_Collantes)
#### Post date: [Janeiro 26, 2017, 9:10pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/2 "2017-01-26T21:10:37Z")

</div>

Not related to your issue, but feverbee board is having other issues too. There seems to be mixed SSL/non content, clicking on users icons render a blank page… something is not right there.

---

<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: [Janeiro 26, 2017, 9:14pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/3 "2017-01-26T21:14:58Z")

</div>

I just signed up and received the two Welcome to FeverBee emails. What are you using for SSO between your website and your forum?

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 9:18pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/4 "2017-01-26T21:18:42Z")

</div>

Thanks for the feedback, but I’m not quite sure what you mean here. Can you give me specifics? User icons?

> [@simon](#):
>
> What are you using for SSO between your website and your forum?

PrimeTime [WP Discourse](https://github.com/discourse/wp-discourse) SSO

---

<div class="post-metadata">

### Author: ![David\_Collantes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david_collantes/32/87919_2.png) [@David\_Collantes](https://meta.discourse.org/u/David_Collantes)
#### Post date: [Janeiro 26, 2017, 9:21pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/5 "2017-01-26T21:21:52Z")

</div>

\<img src=“[//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/7/5/7511f50681dc91d7501a5657e35dd96a143f6c4f.gif](https://global.discourse-cdn.com/meta/original/3X/7/5/7511f50681dc91d7501a5657e35dd96a143f6c4f.gif)” width=“589” height="500”\>

[This is what I meant](https://global.discourse-cdn.com/meta/original/3X/7/5/7511f50681dc91d7501a5657e35dd96a143f6c4f.gif).

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 9:53pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/6 "2017-01-26T21:53:25Z")

</div>

Huh. Only seems to be the case when logged out.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [Janeiro 26, 2017, 10:12pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/7 "2017-01-26T22:12:00Z")

</div>

This is a side effect of “hide user profiles from public” @eviltrout is adding it to his list, the double pm thing is strange, we will also investigate

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 10:13pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/8 "2017-01-26T22:13:26Z")

</div>

All good. Thanks, as always.

---

<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: [Janeiro 26, 2017, 10:34pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/9 "2017-01-26T22:34:48Z")

</div>

I was surprised to be automatically logged into the forum when I created an account on the WordPress site. It seems that on registration a new user is being created on the forum through the API. This will cause Discourse to send the welcome message. It seems that immediately after this, the user is automatically logged into the forum with their SSO credentials. This shouldn’t cause a welcome message to be sent, as the user is active, but possibly something is going wrong here.

I don’t know if it’s a concern, but user emails on your forum are not being validated.

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 11:19pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/10 "2017-01-26T23:19:57Z")

</div>

> [@simon](#):
>
> It seems that on registration a new user is being created on the forum through the API.

Correct.

> [@simon](#):
>
> as the user is active

It’s only sporadic. And even stranger, neither of your new accounts appear to have received two, although you mentioned above that you did.

 ![](https://global.discourse-cdn.com/meta/original/3X/4/f/4fa644195de5a3799619db377987b246b11194a8.png)

 ![](https://global.discourse-cdn.com/meta/original/3X/e/2/e20f5315bc4303ca48192a578fc3b9e720ee6cd0.png)

> [@simon](#):
>
> I don’t know if it’s a concern, but user emails on your forum are not being validated.

It was a conscious decision to streamline the registration process. Decided to give it a try for a while and see whether it caused issues. It hasn’t in almost a year, so not stressed.

---

<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: [Janeiro 26, 2017, 11:30pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/11 "2017-01-26T23:30:04Z")

</div>

Yes, both attempts at doing that were sent two welcome emails. If you want to simplify the login process to Discourse, you could just change the Community link in the header to an SSO link for logged in users. This way, you don’t need to create a user through the API. I’m doing it like this, but it will depend on how your menu is created.

```php
function discourse_community_link( $items, $args ) {
    if ( 'primary' === $args->theme_location ) {
        if ( is_user_logged_in() ) {
            $community_link = '<li><a href="http://localhost:3000/session/sso?return_path=/">Community</a> </li>';
        } else {
            $community_link = '<li><a href="http://localhost:3000">Community</a> </li>';
        }
        $items = $items . $community_link;
    }

    return $items;
}
add_filter( 'wp_nav_menu_items', 'discourse_community_link', 10, 2 );

```

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 11:41pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/12 "2017-01-26T23:41:13Z")

</div>

> [@simon](#):
>
> Yes, both attempts at doing that were sent two welcome emails.

So this is yet another issue then – it was initially the two welcome PMs that I was concerned about. Ugh.

> [@simon](#):
>
> …an SSO link for logged in users.

I’m not sure I quite get what you mean. For logged in users, or for not-yet-registered users?  
If you mean logged in, then doesn’t the user already exist?

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [Janeiro 26, 2017, 11:44pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/13 "2017-01-26T23:44:07Z")

</div>

Further to that – would you mind posting an image of the email that you received two of?  
That issue almost certainly isn’t Discourse related – I think Paid Memberships Pro is sending it from the WP side.

---

<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: [Janeiro 26, 2017, 11:57pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/14 "2017-01-26T23:57:47Z")

</div>

This is the email I was sent twice when I registered:

 ![](https://global.discourse-cdn.com/meta/original/3X/c/9/c913e39d6442b714d101ea7e6de0af0d74b09f43.png)

> [@HAWK](#):
>
> For logged in users, or for not-yet-registered users?

What that code does is create a link that will log a user into your forum if they are logged into your website. If the user doesn’t yet exist on the forum it will create a new user. That way you don’t need to create a user through the API during the registration process. The way your website’s registration process is set up, users are logged into the website when they register, so after registration, if they click on the Community link, it will create an account for them on the forum and log them in.

For user’s who aren’t logged into the website, it will generate a normal link to your homepage.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [Janeiro 27, 2017, 5:46pm UTC](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419/15 "2017-01-27T17:46:29Z")

</div>

This fixes the weird bug of anonymous users clicking on cards when public profiles are disabled:

[https://github.com/discourse/discourse/commit/e3670c52fa2a965f1f9503ee7dc4d49915715da9](https://github.com/discourse/discourse/commit/e3670c52fa2a965f1f9503ee7dc4d49915715da9)
