# Wp-discourse force login to WordPress

**URL:** https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418
**Category:** Support
**Tags:** wordpress
**Created:** [22 mei 2019 om 15:05 UTC](https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418 "2019-05-22T15:05:58Z")
**Posts on this page:** 5
**Page:** 1

<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: [22 mei 2019 om 15:05 UTC](https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418/1 "2019-05-22T15:05:58Z")

</div>

I’ve got a site that’s using WooCommerce Memberships and has Discourse as the SSO master.

For reasons that I don’t understand, `wc_memberships_user_membership_status_changed` doesn’t fire when a new user membership is added (some how that’s not a change?).

So I’ve added a hook on `wp_login`. The only bummer is that when someone subscribes, they need to log out/in to WordPress to get added to the Discourse group.

Would it work to add a webhook in Discourse that fires on `user event` that could solve 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: [22 mei 2019 om 16:17 UTC](https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418/2 "2019-05-22T16:17:08Z")

</div>

The easiest solution might be to find out if there is an action hook that is fired when a membership is added. [wc\_memberships\_user\_membership\_saved](https://docs.woocommerce.com/document/woocommerce-memberships-admin-hook-reference/#wc_memberships_user_membership_saved) might work.

---

<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: [22 mei 2019 om 16:25 UTC](https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418/3 "2019-05-22T16:25:39Z")

</div>

Yeah, that was my idea! As it turns out, what `wc_memberships_user_membership_saved` actually does, doesn’t match the documentation. At all. It passes **two** parameters rather than the **three** documented (which are still different from the `status_changed` hook), and neither of them is what is documented there. (I can’t remember now what actually got passed, but I couldn’t figure out how to get the user or the membership ID out of it.)

I spent what seemed like a week on this yesterday before settling on making people log out/in to WordPress to make it work.

---

<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: [8 oktober 2022 om 01:51 UTC](https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418/4 "2022-10-08T01:51:39Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [9 oktober 2022 om 04:58 UTC](https://meta.discourse.org/t/wp-discourse-force-login-to-wordpress/118418/5 "2022-10-09T04:58:19Z")

</div>


