Wp-discourse force login to WordPress

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?

إعجاب واحد (1)

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 might work.

3 إعجابات

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.

إعجاب واحد (1)