# 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:** 1\
**Showing post:** 11

<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 );

```

---

_[View the full topic](https://meta.discourse.org/t/welcome-pm-is-sometimes-sent-twice/56419)._
