Skip to content
Advertisement

How to use WooCommerce Membership hook

I’m working on a website using WooCommerce membership.

I’m using a hook called wc_memberships_user_membership_saved, What I want is to display a recap of my order.

I read this documentation: https://docs.woocommerce.com/document/woocommerce-memberships-admin-hook-reference/#wc_memberships_user_membership_created on how to use this hook.

I want to test this hook so this is what I did in my functions.php

JavaScript

I should receive a boolean: true or false. But I receive the WooCommerce membership array product instead.

Does the problem come from the params?

Advertisement

Answer

You can use it in the following way, with the $body variable, you can print the parameter(s) to see what it contains

  • @type int|string $user_id user ID for the membership
  • @type int|string $user_membership_id post ID for the new user membership
  • @type bool $is_update true if the membership is being updated, false if new
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement