Sync WooCommerce Memberships with Discourse groups

What changes should I make in my case? I have a little bit different situation. Here are the differencies:

  1. I have Wordpress as a SSO Client, users login via Discourse.
  2. I installed a WP plugin ‘WooCommerce Groups’: Groups WooCommerce Archives - WooCommerce Docs . It’s similar to WooCommerce Memberships but with less functions. I think all core function are the same.
  3. I have multiple groups in Discourse (more than 3) and that’s why 3 groups of access in WP.

Can you provide me with corrections for this code or some advice? Thanks!
May be, you can help? @pfaffman @simon

Ah, I didn’t write a question there…
So I need to activate this integration between WP and Discourse.

What is working:

  1. Wp is working as a SSO client.
  2. Memberships are selling through WP Groups plugin and expiring => users are added to necessary groups.
  3. Users are deleted from groups on expiration.

I need:

  • when user is added to a group in WP I need to add this user to specific group in Discourse
  • when is deleted from that group in WP - delete in Discourse
    Multiple groups in WP and Discourse