WooCommerce Memberships: Quickly Find Out If A User Has Memberships

Here is a quick tip to help find out if a particular user has any memberships. You can drop this function into your custom plugin or theme’s functions.php file
Continue reading WooCommerce Memberships: Quickly Find Out If A User Has Memberships

WooCommerce Memberships: Useful Functions To Know

If you are are just starting to work with WooCommerce Memberships and are having to do various things programatically, here are some functions that are useful to know and will make your life and job a lot easier.

Retrieve User’s Memberships

Retrieve a list of memberships this particular user belongs to. This function will return an array of WC_Memberships_User_Membership objects or NULL if no memberships are found for the user.

Check If User Is An Active Member Of A Particular Membership Plan

Use wc_memberships_is_user_active_member() to quickly figure out if a user is an active member of any of your membership plans

Check If User Is A Member Of A Particular Membership Plan

This function is similar to the the previous one, but it doesn’t not take into consideration the “Active” status.