# Integrate Discourse with MemberMouse

**URL:** <https://meta.discourse.org/t/integrate-discourse-with-membermouse/79636>\
**Category:** Administrators\
**Tags:** wordpress, how-to\
**Created:** [February 2, 2018, 3:10pm UTC](https://meta.discourse.org/t/integrate-discourse-with-membermouse/79636 "2018-02-02T15:10:00Z")\
**Posts on this page:** 1\
**Showing post:** 13

<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:** [February 21, 2018, 4:23pm UTC](https://meta.discourse.org/t/integrate-discourse-with-membermouse/79636/13 "2018-02-21T16:23:43Z")

</div>

Thanks, @simon!

Here’s what I’m doing now:

```php
function add_user_to_discourse($data) {
	do_action( 'my_mm_account_added', $data["username"], get_user_by('ID',$data["member_id"]) );
    error_log ("Doing add_user");
}

add_action('mm_member_add', 'add_user_to_discourse');

```

Also, I have a handful of actions like

```plaintext

add_action('mm_member_membership_change', 'run_discourse_sync_based_on_mm_acct_change');
add_action('mm_member_status_change', 'run_discourse_sync_based_on_mm_acct_change');
add_action('mm_member_account_update', 'run_discourse_sync_based_on_mm_acct_change');

```

Should _all_ of these call `sync_sso_record`? And what should go in `$user` when I call `WPDiscourse\Utilities\Utilities::create_discourse_user( $user )`? (I’m going to RTFC now, but perhaps your 2 minutes can save me an hour. 🙂)

Edit: OK, should something like this work? I see that it’s getting called, but the user’s not getting created.

```plaintext
function add_user_to_discourse($data) {
    $user['name'] = $data['first_name'] . " " . $data['last_name'];
    $user['user_email'] = $data['email'];
    error_log ("Calling create_discourse_user");
    WPDiscourse\Utilities\Utilities::create_discourse_user( $user );
}

```

---

_[View the full topic](https://meta.discourse.org/t/integrate-discourse-with-membermouse/79636)._
