<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Developer Documentation - CODIBU</title>
	<atom:link href="https://help.codibu.com/kbtopic/developer-documentation/feed/" rel="self" type="application/rss+xml" />
	<link>https://help.codibu.com</link>
	<description>Hosting &#38; Domain,  Development &#38; Design, SEO &#38; Marketing, 2300+ Themes &#38; Plugins, Free SEO analysis &#38; tools</description>
	<lastBuildDate>Sun, 08 Nov 2020 13:28:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://help.codibu.com/wp-content/uploads/2022/07/favicon.png</url>
	<title>Developer Documentation - CODIBU</title>
	<link>https://help.codibu.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Teams for WooCommerce Memberships Developer Documentation</title>
		<link>https://help.codibu.com/blog/teams-for-woocommerce-memberships-developer-documentation-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=teams-for-woocommerce-memberships-developer-documentation-2</link>
					<comments>https://help.codibu.com/blog/teams-for-woocommerce-memberships-developer-documentation-2/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sun, 08 Nov 2020 13:28:29 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/teams-for-woocommerce-memberships-developer-documentation-2/</guid>

					<description><![CDATA[<p>This document provides an overview of structure, hooks, and helpful methods in Teams for WooCommerce Memberships. To make adjustments to plugin functionality in an upgrade-safe manner, you<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/teams-for-woocommerce-memberships-developer-documentation-2/">Teams for WooCommerce Memberships Developer Documentation</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>This document provides an overview of structure, hooks, and helpful methods in <a href="https://help.codibu.com/blog/kb/teams-for-woocommerce-memberships-developer-documentation-2/">Teams for WooCommerce Memberships</a>. To make adjustments to plugin functionality in an upgrade-safe manner, you should be very familiar with <a href="http://wp.tutsplus.com/tutorials/the-beginners-guide-to-wordpress-actions-and-filters/">WordPress hooks — actions and filters</a> — as these allow you to make modifications to plugin behavior.</p>
<p>Our goal is to ensure this plugin is easy to work with for customizations. If a hook doesn’t exist where you think it should, please <a href="http://www.woocommerce.com/my-account/create-a-ticket/">submit a ticket</a> so we can consider its addition.</p>
<p>This reference lists helpful filters, actions, and methods and is meant to be a directory. This document may not outline every available or hook or method, so please see the plugin’s inline documentation for additional details on parameters, returned values, and usage, or example usage.</p>
<div class="woo-sc-box note   "><strong>Please be aware</strong> that this document is meant for developers to use as a reference, and some of these code samples are structural samples rather than working snippets. We do not support or do plugin customizations as per our <a href="http://woocommerce.com/support-policy/">support policy</a>. You can <a href="https://woocommerce.com/customizations/">get in touch with an expert</a> for help with customizations.</div>
<p>If you need help changing this code or extending it, we recommend getting in touch with a <a href="https://woocommerce.com/experts/">WooExpert</a> or a developer at Codeable.</p>
<div class="woo-sc-box normal   ">Please be aware that the plugin namespace is: <strong>SkyVergeWooCommerceMembershipsTeams</strong> — references to classes in this document will prefix global namespaces or complete namespaces with a backslash (); a relative class name, such as “Team”, implies that this object would live in the plugin namespace, such as: SkyVergeWooCommerceMembershipsTeamsTeam</div>
<p>&nbsp;</p>
<h2 id="section-1">Data Structure</h2>
<p>Teams for WC Memberships leverages a few custom data structures, but you would also benefit from being familiar with the data structure of WooCommerce Memberships itself. The <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-data-structure/">Memberships Data Structure overview</a> and <a href="https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-extensions/woocommerce-memberships/developers/">developer documentation</a> will be helpful resources.</p>
<p>We also recommend reviewing the methods in the <code>WC_Memberships_User_Membership</code> class, as these methods are quite commonly used by developers to manipulate user memberships. User memberships can easily be instantiated with the <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-function-reference/#wc_memberships_get_user_membership">wc_memberships_get_user_membership()</a> global method.</p>
<p>For its own functionality, Teams adds a “team” and “invitation” custom post type to manage groups of members, and invitations to join a team. Teams also makes modifications to particular products and membership plans to store additional data related to purchasing a team, and managing team access.</p>
<h3 id="section-2">Teams</h3>
<p><strong>Post type</strong>: <code>wc_memberships_team</code></p>
<p>The team post serves as a data store for all team information, such as purchase record, owner, and members (along with the roles of each member on the team).</p>
<p>The team owner is stored as the <strong>post_author</strong>, given a team can only have one owner, and the configured team name is stored as the <strong>post_title</strong>. The team’s <strong>post_parent</strong> is the post ID of the Membership Plan to which the team grants access (as currently a team can only provide access to a single plan).</p>
<p>Team posts store other data about the team as well:</p>
<table>
<thead>
<tr>
<th>META KEY</th>
<th>DATA TYPE</th>
<th>STORED VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>_product_id</td>
<td>int</td>
<td>the ID for the product that was purchased to create the team</td>
</tr>
<tr>
<td>_order_id</td>
<td>int</td>
<td>the ID for the order in which the team was purchased</td>
</tr>
<tr>
<td>_subscription_id</td>
<td>int</td>
<td>if the team was purchased via a subscription product, this is the ID of the subscription to which access is tied</td>
</tr>
<tr>
<td>_seat_count</td>
<td>int</td>
<td>the maximum number of available seats on this team</td>
</tr>
<tr>
<td>_member_id</td>
<td>int</td>
<td>the ID of a member on the team; <strong>there can be multiple pieces of <code>_member_id</code> metadata if multiple seats are occupied</strong></td>
</tr>
<tr>
<td>_membership_end_date</td>
<td>string</td>
<td>the day membership start to expire, based on the plan length; <strong>owners cannot remove members</strong> after this date if removals are enabled</td>
</tr>
</tbody>
</table>
<h3 id="section-3">Team Invitation</h3>
<p><strong>Post type</strong>: <code>wc_team_invitation</code></p>
<p>Invitation posts store data about invitations sent to particular emails. The invitation post will use custom statuses to determine the invitation status: <code>wcmti-pending</code>, <code>wcmti-accepted</code>, or <code>wcmti-cancelled</code>. The <strong>post_author</strong> is the user who sent the invitation, while the <strong>post_parent</strong> is the team to which the invitation belongs.</p>
<p>Pending invitations will store no meta, but accepted invitations will add 2 pieces of meta data:</p>
<table>
<thead>
<tr>
<th>META KEY</th>
<th>DATA TYPE</th>
<th>STORED VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>_accepted_user_id</td>
<td>int</td>
<td>the user ID of the customer who accepted the invitation</td>
</tr>
<tr>
<td>_accepted_date</td>
<td>string</td>
<td>the date on which the invitation was accepted</td>
</tr>
</tbody>
</table>
<h3 id="section-4">Product Data</h3>
<p>To associate a team with a product or variation, the product post will store a few pieces of data:</p>
<table>
<thead>
<tr>
<th>META KEY</th>
<th>DATA TYPE</th>
<th>STORED VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>_wc_memberships_for_teams_has_team_membership</td>
<td>string</td>
<td>yes or no</td>
</tr>
<tr>
<td>_wc_memberships_for_teams_pricing</td>
<td>string</td>
<td>per_member or per_team (dictates the pricing fields for the team)</td>
</tr>
<tr>
<td>_wc_memberships_for_teams_max_member_count</td>
<td>int</td>
<td>the maximum seats that a team can have upon purchase</td>
</tr>
<tr>
<td>_wc_memberships_for_teams_min_member_count</td>
<td>int</td>
<td>the minimum seats required to purchase a team</td>
</tr>
<tr>
<td>_wc_memberships_for_teams_plan</td>
<td>int</td>
<td>the ID of the membership plan to which the team will have access</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2 id="section-5">User capabilities</h2>
<p>Teams provides a few custom WP User capabilities for both admin management of teams, and frontend management for team owners and managers.</p>
<table>
<thead>
<tr>
<th>CAPABILITY</th>
<th>DESCRIPTION</th>
<th>DEFAULT ROLES</th>
</tr>
</thead>
<tbody>
<tr>
<td>memberships_team</td>
<td>grants admin access to manage teams</td>
<td>WP: administrator<br />
WP: shop manager</td>
</tr>
<tr>
<td>wc_memberships_for_teams_renew_team_membership</td>
<td>lets a user renew team access</td>
<td>team owner</td>
</tr>
<tr>
<td>wc_memberships_for_teams_manage_team_settings</td>
<td>lets a user manage team settings (e.g., name)</td>
<td>team owner</td>
</tr>
<tr>
<td>wc_memberships_for_teams_manage_team<br />
wc_memberships_for_teams_manage_team_members</td>
<td>lets a user manage a team and which members belong</td>
<td>team owner<br />
team manager</td>
</tr>
<tr>
<td>wc_memberships_for_teams_remove_team_member</td>
<td>lets a user remove team members</td>
<td>team owner<br />
team manager</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2 id="section-6">Team Lifecycle</h2>
<p>You can hook into the team lifecycle at several instances to fire third party code or adjust teams.</p>
<h3 id="section-7">Created Team Filters</h3>
<p>When a new team is created, the team data can be filtered.</p>
<h4 id="wc_memberships_for_teams_new_team_data">wc_memberships_for_teams_new_team_data</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $data team data</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args an array of team arguments {</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>@type</strong> string $name the team name</li>
<li><strong>@type</strong> int $plan_id the plan id the team has access to</li>
<li><strong>@type</strong> int $owner_id the user id the team is assigned to</li>
<li><strong>@type</strong> int $product_id the product id that creates the team (optional)</li>
<li><strong>@type</strong> int $order_id the order id that contains the product that creates the team (optional)</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<h3 id="section-8">Created Team Actions</h3>
<p>Team creation and management also fires several actions that can be used to run additional code.</p>
<h4 id="wc_memberships_for_teams_team_created">wc_memberships_for_teams_team_created</h4>
<p>Fires after a team has been created. This action hook is similar to <code>wc_memberships_for_teams_team_saved</code> but doesn’t fire when teams are manually created from admin.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>Team $team the team that was just created</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $updating whether this is a post update or a newly created team</dd>
</dl>
<h4 id="wc_memberships_for_teams_team_saved">wc_memberships_for_teams_team_saved</h4>
<p>Fires after a team has been created. This action hook is similar to <code>wc_memberships_for_teams_team_created</code> but will also fire when a team is manually created in admin, or upon an import or via command line interface, etc.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>Team $team the team that was just saved</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $updating whether this is a post update or a newly created team</dd>
</dl>
<h4 id="wc_memberships_for_teams_process_team_meta">wc_memberships_for_teams_process_team_meta</h4>
<p>Fires when a team is saved/updated from admin.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $post_id post identifier</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WP_Post $post the post object</dd>
</dl>
<p>&nbsp;</p>
<h2 id="section-9">Invitation Lifecycle</h2>
<p>You can hook into the team lifecycle at several instances to fire third party code or adjust invitations.</p>
<h3 id="section-10">Created Invitation Filters</h3>
<p>When a new invitation is created, the invitation data can be filtered.</p>
<h4 id="wc_memberships_for_teams_new_invitation_post_data">wc_memberships_for_teams_new_invitation_post_data</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $data new invitation post data</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args array of Invitation arguments {</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>@type</strong> string $email email of the invitation recipient</li>
<li><strong>@type</strong> int $team_id the team id</li>
<li><strong>@type</strong> int $sender_id the sender user id</li>
<li><strong>@type</strong> string $role the role to assign the invited user to</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<h4 id="wc_memberships_for_teams_join_team_redirect_to">wc_memberships_for_teams_join_team_redirect_to</h4>
<p>Filters the URL to redirect to when a user joins a team by invitation or via link</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.4</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $redirect_to URL to redirect to</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $team the team object</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>false|SkyVergeWooCommerceMembershipsTeamsInvitation $invitation the invitation object</dd>
</dl>
<h3 id="section-11">Created Invitation Actions</h3>
<p>Invitation creation will also fire an action that can be used to run additional code.</p>
<h4 id="wc_memberships_for_teams_invitation_created">wc_memberships_for_teams_invitation_created</h4>
<p>Fires after an invitation has been created.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsInvitation $invitation the invitation that was just created</dd>
</dl>
<p>&nbsp;</p>
<h2 id="section-12">Frontend Hooks</h2>
<p>This is a non-exhaustive list; these represent some often-used frontend hooks.</p>
<h3 id="section-13">Frontend Filters</h3>
<h4 id="wc_memberships_for_teams_product_team_user_input_fields">wc_memberships_for_teams_product_team_user_input_fields</h4>
<p>Filters user input fields for a team product.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $fields associative array of user input fields</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product the product</dd>
</dl>
<h4 id="wc_memberships_for_teams_add_team_member_form_fields">wc_memberships_for_teams_add_team_member_form_fields</h4>
<p>Filters form fields for the add team member form on frontend.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $fields associative array of form fields</dd>
</dl>
<h4 id="wc_memberships_team_teams_area_sections">wc_memberships_team_teams_area_sections</h4>
<p>Filters the available sections for the teams area.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $sections associative array with teams area id and label of each section</dd>
</dl>
<h4 id="wc_memberships_for_teams_teams_area_section_id_title">wc_memberships_for_teams_teams_area_{$section_id}_title</h4>
<p>Filters the teams area section name title. Core section IDs include “members”, “add-member”, and “settings”.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $section_name the section name (e.g. “Members”, “Add Member”, “Settings”…)</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>Team $team the current team displayed</dd>
</dl>
<h4 id="wc_memberships_for_teams_teams_area_my_team_details">wc_memberships_for_teams_teams_area_my_team_details</h4>
<p>Filters the teams area team details.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $details associative array of settings labels and HTML content for each row</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>Team $team the team the details are for</dd>
</dl>
<h3 id="section-14">Frontend Actions</h3>
<h4 id="wc_memberships_for_teams_before_renewal_auto_login">wc_memberships_for_teams_before_renewal_auto_login</h4>
<p>Fires right before logging a team member in. Can throw <code>SV_WC_Plugin_Exception</code> to halt the login completely.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $log_in_user_id the user ID of the member to log in</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $team team instance</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $allow_login whether automatic log in is allowed</dd>
</dl>
<p>&nbsp;</p>
<h2 id="section-15">Admin Hooks</h2>
<p>This is a non-exhaustive list; these represent some often-used admin hooks.</p>
<h3 id="section-16">Admin Filters</h3>
<h4 id="wc_memberships_for_teams_team_member_roles">wc_memberships_for_teams_team_member_roles</h4>
<p>Filters the list of available team member roles. Note that this does not include owner by design.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $roles an associative array of role =&gt; label pairs</dd>
</dl>
<h4 id="wc_memberships_for_teams_settings">wc_memberships_for_teams_settings</h4>
<p>Filters Memberships for Teams settings.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $settings array of teams settings</dd>
</dl>
<h4 id="wc_memberships_for_teams_invitation_statuses">wc_memberships_for_teams_invitation_statuses</h4>
<p>Filters invitation statuses.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $statuses associative array of statuses and their arguments</dd>
</dl>
<h4 id="wc_memberships_for_teams_skip_invitations">wc_memberships_for_teams_skip_invitations</h4>
<p>Filters sending an invitation when adding members to a team</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.2</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $skip_invitations whether invitations should be skipped</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>null|SkyVergeWooCommerceMembershipsTeamsTeam optional argument to evaluate if invitations should be skipped for a particular team</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>null|int|string|WP_User optional entity being invited to join a team (either email, ID or object)</dd>
</dl>
<h4 id="wc_memberships_for_teams_team_membership_can_be_renewed">wc_memberships_for_teams_team_membership_can_be_renewed</h4>
<p>Filters whether a team membership can be renewed</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $can_be_renewed whether can be renewed by a user</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $team the team to renew membership for</dd>
</dl>
<h4 id="wc_memberships_for_teams_team_management_status">wc_memberships_for_teams_team_management_status</h4>
<p>Filters team management status</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array an associative array with two keys: “can_be_managed” and “messages”</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $team the related team</dd>
</dl>
<h4 id="wc_memberships_for_teams_team_can_add_seats">wc_memberships_for_teams_team_can_add_seats</h4>
<p>Filters whether a team can have seats added</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $can_add_seats whether seats can be added</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $this the Team object</dd>
</dl>
<h4 id="wc_memberships_for_teams_team_can_remove_seats">wc_memberships_for_teams_team_can_remove_seats</h4>
<p>Filters whether a team can have seats removed</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $can_remove_seats whether seats can be removed</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $this the Team object</dd>
</dl>
<h4 id="wc_memberships_for_teams_allow_editing_user_membership">wc_memberships_for_teams_allow_editing_user_membership</h4>
<p>Filters the editing of a user membership</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.2</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $allow_edit default true for non-subscription linked memberships</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership|WC_Memberships_Integration_Subscriptions_User_Membership $user_membership membership object</dd>
</dl>
<h4 id="wc_memberships_for_teams_should_perform_seat_change">wc_memberships_for_teams_should_perform_seat_change</h4>
<p>Filters whether a seat change should be performed</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $should_perform_seat_change</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $this the Team object</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $new_seat_count the desired seat count</dd>
</dl>
<h4 id="wc_memberships_for_teams_should_prorate_seat_change">wc_memberships_for_teams_should_prorate_seat_change</h4>
<p>Filters whether a seat change should be prorated</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $should_prorate_seat_change default false</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $this the Team object</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $new_seat_count the desired seat count</dd>
</dl>
<h4 id="wc_memberships_for_teams_seat_change_notice_message">wc_memberships_for_teams_seat_change_notice_message</h4>
<p>Filters the notice message that is shown after a successful seat change</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.1.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $seat_change_message the notice message</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Order $order the order object</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Order_Item $item the order item object that contains the seat change data</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $this the Team object</dd>
</dl>
<h3 id="section-17">Admin Actions</h3>
<h4 id="wc_memberships_for_teams_before_team_billing_details">wc_memberships_for_teams_before_team_billing_details</h4>
<p>Fires before the billing details in edit team screen.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $team the team instance</dd>
</dl>
<h4 id="wc_memberships_for_teams_after_team_billing_details">wc_memberships_for_teams_after_team_billing_details</h4>
<p>Fires before the billing details in edit team screen.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>SkyVergeWooCommerceMembershipsTeamsTeam $team the team instance</dd>
</dl>
<p>&nbsp;</p>
<h2 id="section-18">Methods and Global Functions</h2>
<p>This is a non-exhaustive list; these represent some often-used plugin methods.</p>
<h3 id="section-19">Plugin main class</h3>
<p>The instance of the main plugin class can be accessed with: <code>wc_memberships_for_teams()</code></p>
<p>Any other plugin classes are instantiated in this main plugin class, or another class that’s instantiated by the main plugin class. Therefore, if you want to unhook methods in a particular class, you’ll need to use this helper to access the class instance. For example, many classes are instantiated by the main plugin class, and can be accessed with:</p>
<pre>wc_memberships_for_teams()-&gt;get_*_instance()</pre>
<p>For example:</p>
<pre>wc_memberships_for_teams()-&gt;get_orders_instance()</pre>
<p>Classes that are not instantiated in the main plugin class can be accessed through instances of the class that instantiates them:</p>
<pre>wc_memberships_for_teams()-&gt;get_frontend_instance()-&gt;get_teams_area_instance()</pre>
<h3 id="section-20">Teams object</h3>
<p>While we won’t list every method here, the <code>Team</code> object is a good one to review, as this provides methods to get or set almost any piece of team data, or programmatically process seat changes, member invites, adding or removing members, etc.</p>
<p>An instance of this class can be accessed with:</p>
<pre>wc_memberships_for_teams_get_team( $team_id_or_post )</pre>
<h3 id="section-21">Conditional Checks</h3>
<p>There are a few conditional checks that can help you determine team or product information.</p>
<h4 id="wc_memberships_for_teams_is_valid_team_member_role-role-">wc_memberships_for_teams_is_valid_team_member_role( $role )</h4>
<p>Checks if a team member role is valid or not.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $role the role to check</dd>
</dl>
<h4 id="skyvergewoocommercemembershipsteamsproducthas_team_membership-product-">SkyVergeWooCommerceMembershipsTeamsProduct::has_team_membership( $product )</h4>
<p>Checks if a product has a team membership attached (purchasing this product creates a team). <strong>You must pass an instance of WC_Product</strong> to this method.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product</dd>
</dl>
<h4 id="skyvergewoocommercemembershipsteamsproducthas_per_member_pricing-product-">SkyVergeWooCommerceMembershipsTeamsProduct::has_per_member_pricing( $product )</h4>
<p>Checks if a product uses per-member pricing (false if per-team pricing is used). <strong>You must pass an instance of WC_Product</strong> to this method.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product</dd>
</dl>
<h3 id="section-22">Global &amp; Static Functions</h3>
<p>A non-exhaustive list of some helpful global and static methods for use in customizations.</p>
<h4 id="skyvergewoocommercemembershipsteamsproductget_min_member_count-product-">SkyVergeWooCommerceMembershipsTeamsProduct::get_min_member_count( $product )</h4>
<p>Gets the minimum member count required to purchase the team product; returns the integer count or <code>null</code> if not set. <strong>You must pass an instance of WC_Product</strong> to this method.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product</dd>
</dl>
<h4 id="skyvergewoocommercemembershipsteamsproductget_max_member_count-product-">SkyVergeWooCommerceMembershipsTeamsProduct::get_max_member_count( $product )</h4>
<p>Gets the maximum member count allowed when purchasing the team product; returns the integer count or <code>null</code> if not set. <strong>You must pass an instance of WC_Product</strong> to this method.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product</dd>
</dl>
<h4 id="skyvergewoocommercemembershipsteamsproductget_membership_plan_id-product-">SkyVergeWooCommerceMembershipsTeamsProduct::get_membership_plan_id( $product )</h4>
<p>Gets the membership plan ID that will be granted to a team created via this product; returns the integer count or <code>null</code> if not set. <strong>You must pass an instance of WC_Product</strong> to this method.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product</dd>
</dl>
<h4 id="wc_memberships_for_teams_get_team-id_or_post-">wc_memberships_for_teams_get_team( $id_or_post )</h4>
<p>Can be used to get an instance of a team. Accepts the team post object or post ID. Returns a <code>Team</code> instance if found, or false on failure.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|WP_Post $post optional team id or post object, defaults to current global post object</dd>
</dl>
<h4 id="wc_memberships_for_teams_get_teams-user_id-args-return-force_refresh-">wc_memberships_for_teams_get_teams( $user_id, $args, $return, $force_refresh )</h4>
<p>Returns a list of teams for a user (should be preferred over <code>get_posts()</code> calls to protect against data structure changes). Can return either a plain list of team objects or an associative array with query results and team objects, and will return false on failure.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id optional, defaults to current user</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args an array of arguments to pass to WP_Query – additionally, a few special arguments can be passed: {</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>@type</strong> string|array $status team status, defaults to ‘any’</li>
<li><strong>@type</strong> string|array $role a comma-separated list or array of team member roles, defaults to ‘owner, manager’ – specifying this will only fetch teams that the user has one of the given roles</li>
<li><strong>@type</strong> int $paged the page number for paging the results (corresponds to paged param for get_posts())</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $return (optional) what to return – set to ‘query’ to return the WP_Query instance instead of a list of invitation instances</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $force_refresh (optional) whether to force reloading the results even if a previous result has been memoized, defaults to false</dd>
</dl>
<h4 id="wc_memberships_for_teams_get_user_membership_team-user_membership_id-">wc_memberships_for_teams_get_user_membership_team( $user_membership_id )</h4>
<p>Returns the team for a given user membership, if any. Returns false if the membership does not belong to a team.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_membership_id user membership id</dd>
</dl>
<h4 id="wc_memberships_for_teams_get_team_members-team_id-args-return-null-">wc_memberships_for_teams_get_team_members( $team_id, $args, $return, $null )</h4>
<p>Returns a list of team members given the input query (should be preferred over <code>get_posts()</code> calls to protect against data structure changes). Can return either a plain list of team member objects or an associative array with query results and team member objects.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|SkyVergeWooCommerceMembershipsTeamsTeam $team_id team id or instance to get the team members for</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args (optional) an array of arguments to pass to WP_Query – additionally, a few special arguments can be passed: {</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>@type</strong> string|array $role a comma-separated list or array of team member roles, empty by default – specifying this will only fetch members with the given role</li>
<li><strong>@type</strong> int $paged the page number for paging the results, corresponds to paged param for get_users()</li>
<li><strong>@type</strong> int $per_page the number of team members to fetch per page, corresponds to the number param for get_users()</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $return (optional) what to return – set to ‘query’ to return the WP_User_Query instance instead of a list of team member instances</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $force_refresh (optional) whether to force reloading the results even if a previous result has been memoized, defaults to false</dd>
</dl>
<h4 id="wc_memberships_for_teams_get_team_member_roles">wc_memberships_for_teams_get_team_member_roles()</h4>
<p>Returns a an associative array of available team member roles.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
</dl>
<h4 id="wc_memberships_for_teams_create_team-args-">wc_memberships_for_teams_create_team( $args )</h4>
<p>Programmatically creates a team. Returns a new <code>Team</code> object on success which can then be used to add additional data, but will return <code>SV_WC_Plugin_Exception</code> on failure.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args (see below)</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $action ‘create’ or ‘renew’; defaults to ‘create’</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>Team|SV_WC_Plugin_Exception</dd>
</dl>
<p>The arguments you can pass in to create a new team are as follows:</p>
<table>
<thead>
<tr>
<th>ARRAY KEY</th>
<th>DATA TYPE</th>
<th>REQUIRED</th>
<th>VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>owner_id</td>
<td>int</td>
<td><strong>required</strong></td>
<td>owner user ID</td>
</tr>
<tr>
<td>plan_id</td>
<td>int|WC_Memberships_Plan</td>
<td><strong>required</strong></td>
<td>plan ID or instance to which the team will have access</td>
</tr>
<tr>
<td>product_id</td>
<td>int|WC_Product</td>
<td>–</td>
<td>product ID or instance that can be used to purchase the team; required if a team should be renewable</td>
</tr>
<tr>
<td>order_id</td>
<td>intWC_Order</td>
<td>–</td>
<td>ID or instance of the order in which the team was purchased</td>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td>–</td>
<td>team name; defaults to “Team”</td>
</tr>
<tr>
<td>seats</td>
<td>int</td>
<td>–</td>
<td>the seat count for the team; if not provided, product_id must be specified, and the team will use the max member count from the product/variation</td>
</tr>
</tbody>
</table>
<h4 id="wc_memberships_for_teams_create_invitation-args-">wc_memberships_for_teams_create_invitation( $args )</h4>
<p>Programmatically creates a team invitation. Returns a new <code>Invitation</code> object on success which can then be used to add additional data, but will throw <code>SV_WC_Plugin_Exception</code> on failure.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args (see below)</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>Invitation|SV_WC_Plugin_Exception</dd>
</dl>
<p>The arguments you can pass in to create a new invitation are as follows:</p>
<table>
<thead>
<tr>
<th>ARRAY KEY</th>
<th>DATA TYPE</th>
<th>REQUIRED</th>
<th>VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>team_id</td>
<td>int|object</td>
<td><strong>required</strong></td>
<td>team ID or instance for the invitation</td>
</tr>
<tr>
<td>email</td>
<td>string</td>
<td><strong>required</strong></td>
<td>the email address to which the invitation should be sent</td>
</tr>
<tr>
<td>sender_id</td>
<td>int</td>
<td>–</td>
<td>the sender’s user ID (default: current user)</td>
</tr>
<tr>
<td>role</td>
<td>string</td>
<td>–</td>
<td>the team role to assign to the invited user, defaults to ‘member’</td>
</tr>
</tbody>
</table>
<h4 id="wc_memberships_for_teams_get_invitation-id-email-">wc_memberships_for_teams_get_invitation( $id, $email )</h4>
<p>Returns a specific invitation for a team, or false on failure.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string|int|WP_Post|Invitation|Team $id invitation token, id, or instance; or team id or instance</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $email (optional) invitation recipient email, required if $id is a team id or instance</dd>
</dl>
<h4 id="wc_memberships_for_teams_get_invitations-team_id-args-return-force_refresh-">wc_memberships_for_teams_get_invitations( $team_id, $args, $return, $force_refresh )</h4>
<p>Returns a list of invitations (should be preferred over <code>get_posts()</code> calls to protect against data structure changes). Can return either a plain list of invitation objects or an associative array with query results and invitation objects.</p>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $team_id team id to get the invitations for</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args an array of arguments to pass to WP_Query – additionally, a few special arguments can be passed: {</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>@type</strong> string|array $status invitation status, defaults to ‘pending’, can be used instead of $post_status</li>
<li>string|array $role a comma-separated list or array of team member roles, empty by default – specifying this will only fetch invitations that grant the one of thge specified roles for the user</li>
<li><strong>@type</strong> int $paged the page number for paging the results, corresponds to paged param for get_posts()</li>
<li><strong>@type</strong> int $per_page the number of invitations to fetch per page, corresponds to the posts_per_page param for get_posts()</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>@param string $return (optional) what to return – set to ‘query’ to return the WP_Query instance instead of a list of invitation instances</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $force_refresh (optional) whether to force reloading the results even if a previous result has been memoized, defaults to false</dd>
</dl>
<h2 id="section-23">User Documentation</h2><p>The post <a href="https://help.codibu.com/blog/teams-for-woocommerce-memberships-developer-documentation-2/">Teams for WooCommerce Memberships Developer Documentation</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/teams-for-woocommerce-memberships-developer-documentation-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WooCommerce Memberships – CLI Reference</title>
		<link>https://help.codibu.com/blog/woocommerce-memberships-cli-reference/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=woocommerce-memberships-cli-reference</link>
					<comments>https://help.codibu.com/blog/woocommerce-memberships-cli-reference/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sat, 07 Nov 2020 12:51:19 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/woocommerce-memberships-cli-reference/</guid>

					<description><![CDATA[<p>Overview Starting from Memberships 1.13.0, the CLI implementation has switched to WC REST API. While the legacy WP CLI commands will still work, they are currently<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-cli-reference/">WooCommerce Memberships – CLI Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<h2 id="section-1">Overview</h2>
<div class="woo-sc-box normal   ">Starting from Memberships 1.13.0, the CLI implementation has switched to WC REST API. While the legacy WP CLI commands will still work, they are currently deprecated and will be removed at a later date.</div>
<p>You can manage WooCommerce Memberships plans and members via WP CLI if installed in your environment. There are two additional subcommands added to the WC CLI implementation: <code>user_membership</code> and <code>membership_plan</code>.</p>
<p>For further details please see the CLI help topics: <code>wp help wc user_membership</code> and <code>wp help wc membership_plan</code>.</p>
<p>All versions can still use our legacy WP CLI implementation too. This will allow you to use the primary command of <code>wp wc memberships</code> followed by our sub-commands:</p>
<ul>
<li><strong>memberships</strong> – manage user memberships</li>
<li><strong>plan</strong> – manage membership plans</li>
</ul>
<p>If you are looking to create and edit membership plans, then you will need to <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-cli-reference/">use the legacy CLI</a> for the time being. You can also use <code>wp help wc memberships</code> for additional information and in-context help.</p>
<p>&nbsp;</p>
<h2 id="section-2">wp wc membership_plan</h2>
<p>You can read plans with the <code>wp wc membership_plan</code> subcommands:</p>
<table>
<thead>
<tr>
<th>COMMAND</th>
<th>FUNCTION</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>get</code></td>
<td>Get a membership plan</td>
</tr>
<tr>
<td><code>list</code></td>
<td>List membership plans</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3 id="section-3">wp wc membership_plan get</h3>
<p>Get data associated with a membership plan by ID:<br />
<code>wp wc membership_plan get 123</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string – the field to get values for, e.g., <code>--field="members_count"</code> (slug, id, name, type, length, members_count, etc)</td>
</tr>
<tr>
<td>fields</td>
<td>string – comma-separated list of fields to get values for, e.g., <code>--fields="slug,members_count"</code></td>
</tr>
<tr>
<td>format</td>
<td>string – the desired format for requested date, e.g., <code>--format="json"</code> (table, json, csv)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="get-plan-examples">Get plan examples</h4>
<dl>
<dt><code>wp wc membership_plan get 246</code></dt>
<dd>Gets all fields for plan 246</dd>
<dt><code>wp wc membership_plan get 343 --fields="id,slug,type,length,members_count"</code></dt>
<dd>Gets a selection of fields for plan 343</dd>
<dt><code>wp wc membership_plan get 8761 --format="json"</code></dt>
<dd>Gets plan data for membership plan 8761 in JSON formation</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-4">wp wc membership_plan list</h3>
<p>Lists data associated with membership plans:<br />
<code>wp wc membership_plan list</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string – print the value of a single field for all plans, e.g., <code>--field="members_count"</code> (slug, id, name, type, length, product_ids, members_count, status, start_date, end_date)</td>
</tr>
<tr>
<td>fields</td>
<td>string – comma-separated list of fields to print values for, e.g., <code>--fields="slug,members_count"</code></td>
</tr>
<tr>
<td>format</td>
<td>string – the desired format for requested date, e.g., <code>--format="json"</code> (table, csv, json, count, ids)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="plan-list-examples">Plan list examples</h4>
<dl>
<dt><code>wp wc membership_plan list</code></dt>
<dd>Outputs a table of default data for all plans</dd>
<dt><code>wp wc membership_plan list --format="csv"</code></dt>
<dd>Provides a CSV formatted result of all membership plans</dd>
<dt><code>wp wc membership_plan list --fields="slug,members_count"</code></dt>
<dd>Outputs a list of plans with only the slug and member count.</dd>
</dl>
<p>&nbsp;</p>
<h2 id="section-5">wp wc user_membership</h2>
<p>You can manage user memberships with <code>wp wc user_membership</code> subcommands:</p>
<table>
<thead>
<tr>
<th>COMMAND</th>
<th>FUNCTION</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>create</code></td>
<td>Create a new user membership</td>
</tr>
<tr>
<td><code>delete</code></td>
<td>Delete an existing user membership</td>
</tr>
<tr>
<td><code>get</code></td>
<td>Get a user membership</td>
</tr>
<tr>
<td><code>list</code></td>
<td>List user memberships</td>
</tr>
<tr>
<td><code>import</code></td>
<td>Import user memberships</td>
</tr>
<tr>
<td><code>update</code></td>
<td>Update one or more user memberships</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3 id="section-6">wp wc user_membership create</h3>
<p>Allows you to create new user membership.</p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>REQUIRED?</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>customer_id</td>
<td>yes</td>
<td>int – the user ID for the member, e.g., <code>--customer_id=22</code></td>
</tr>
<tr>
<td>plan_id</td>
<td>yes</td>
<td>int|string – plan ID or slug, e.g., <code>--plan_id="silver-plan"</code></td>
</tr>
<tr>
<td>status</td>
<td>no</td>
<td>string – membership status, e.g., <code>--status="paused"</code></td>
</tr>
<tr>
<td>order_id</td>
<td>no</td>
<td>int – ID of order that granted access, e.g., <code>--order_id=123</code></td>
</tr>
<tr>
<td>product_id</td>
<td>no</td>
<td>int – ID of product that granted access, e.g., <code>--product_id=46</code></td>
</tr>
<tr>
<td>start_date_gmt</td>
<td>no</td>
<td>string – start date for the user membership in UTC, e.g., <code>"2017-01-01"</code></td>
</tr>
<tr>
<td>end_date_gmt</td>
<td>no</td>
<td>string – end date for the user membership in UTC, e.g., <code>"2017-12-31"</code></td>
</tr>
<tr>
<td>cancelled_date_gmt</td>
<td>no</td>
<td>string – cancellation date for the user membership in UTC, e.g., <code>"2017-01-01"</code></td>
</tr>
<tr>
<td>paused_date_gmt</td>
<td>no</td>
<td>string – last paused date for the user membership in UTC, e.g., <code>"2017-12-31"</code></td>
</tr>
<tr>
<td>meta_data</td>
<td>no</td>
<td>array – any WordPress post meta data to be set on the membership. Each array item has an “id” (integer), a “key” (string) and a “value” (either a boolean, an integer, or string, which could also represent serialized data).</td>
</tr>
<tr>
<td>subscription_id</td>
<td>no</td>
<td>int – ID of subscription the membership is tied to, e.g., <code>--subscription_id=125</code></td>
</tr>
<tr>
<td>subscription</td>
<td>no</td>
<td>int – ID of subscription the membership is tied to, e.g., <code>--subscription=125</code></td>
</tr>
<tr>
<td>installment_plan</td>
<td>no</td>
<td>string – if the user membership should be part of an installment plan (“Y” or “N”) e.g., <code>--installment_plan="Y"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="user-membership-creation-examples">User Membership creation examples</h4>
<dl>
<dt><code>wp wc user_membership create --customer_id=83 --plan_id=238</code></dt>
<dd>Creates an unlimited membership for user 83 to plan 238</dd>
<dt><code>wp wc user_membership create --customer_id=101 --plan_id="silver" --start_date_gmt="2016-01-01" --end_date_gmt="2016-06-30" --status="expired"</code></dt>
<dd>Creates an expired silver membership for user 101 that started on Jan 1, 2016, and ended on June 30, 2016</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-7">wp wc user_membership delete</h3>
<p>Deletes a user membership using ID:<br />
<code>wp wc user_membership delete 101</code></p>
<p>You can also delete all members at once:<br />
<code>wp wc user_membership delete $(wp wc user_membership list --format=ids)</code></p>
<p>&nbsp;</p>
<h3 id="section-8">wp wc user_membership update</h3>
<p>Allows you to update user memberships using the user membership ID:<br />
<code>wp wc user_membership update 9809</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>plan_id</td>
<td>int|string – new plan plan ID or slug, e.g., <code>--plan_id="gold-plan"</code></td>
</tr>
<tr>
<td>status</td>
<td>string – updated membership status, e.g., <code>--status="cancelled"</code></td>
</tr>
<tr>
<td>start_date_gmt</td>
<td>string – updated start date for the user membership, e.g., <code>"2017-07-01"</code></td>
</tr>
<tr>
<td>end_date_gmt</td>
<td>string – updated end date for the user membership, e.g., <code>"2018-07-01"</code></td>
</tr>
<tr>
<td>paused_date_gmt</td>
<td>string – last paused date for the user membership in UTC, e.g., <code>"2017-12-31"</code></td>
</tr>
<tr>
<td>cancelled_date_gmt</td>
<td>string – cancellation date for the user membership in UTC, e.g., <code>"2017-01-01"</code></td>
</tr>
<tr>
<td>meta_data</td>
<td>array – any WordPress post meta data to be set on the membership. Each array item has an “id” (integer), a “key” (string) and a “value” (either a boolean, an integer, or string, which could also represent serialized data).</td>
</tr>
<tr>
<td>subscription_id</td>
<td>int – ID of subscription the membership is tied to, e.g., <code>--subscription_id=125</code></td>
</tr>
<tr>
<td>subscription</td>
<td>int – ID of subscription the membership is tied to, e.g., <code>--subscription=125</code></td>
</tr>
<tr>
<td>installment_plan</td>
<td>string – if the user membership should be part of an installment plan (“Y” or “N”) e.g., <code>--installment_plan="Y"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="user-membership-update-examples">User Membership update examples</h4>
<dl>
<dt><code>wp wc user_membership update 8762 --end_date_gmt="2017-01-01" --status="active"</code></dt>
<dd>Updates the end date and status of user membership 8762</dd>
<dt><code>wp wc user_membership update 776 --plan_id=126</code></dt>
<dd>Changes user membership 776 to use plan 126</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-9">wp wc user_membership get</h3>
<p>Get data associated with a user membership by ID:<br />
<code>wp wc user_membership get 653</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string – the field to get values for, e.g., <code>--field="status"</code> (id, user_id, plan_id, plan, status, start_date, end_date)</td>
</tr>
<tr>
<td>fields</td>
<td>string – comma-separated list of fields to get values for, e.g., <code>--fields="plan,status"</code></td>
</tr>
<tr>
<td>format</td>
<td>string – the desired format for requested date, e.g., <code>--format="json"</code> (table, json, csv)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="get-user-membership-examples">Get user membership examples</h4>
<dl>
<dt><code>wp wc user_membership get 848</code></dt>
<dd>Gets all fields for user membership 848</dd>
<dt><code>wp wc user_membership get 848 --fields="plan,status"</code></dt>
<dd>Gets the plan and status for user membership 848</dd>
<dt><code>wp wc user_membership get 848 --format="json"</code></dt>
<dd>Gets data for user membership 848 in JSON formation</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-10">wp wc user_membership list</h3>
<p>Lists data associated with all user memberships:<br />
<code>wp wc user_membership list</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string – print the value of a single field for all memberships, e.g., <code>--field="user_id"</code> (id, user_id, plan_id, plan, status, start_date, end_date, subscription)</td>
</tr>
<tr>
<td>fields</td>
<td>string – comma-separated list of fields to print values for, e.g., <code>--fields="plan,status"</code></td>
</tr>
<tr>
<td>format</td>
<td>string – the desired format for requested date, e.g., <code>--format="json"</code> (table, csv, json, count, ids)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="user-membership-list-examples">User Membership list examples</h4>
<dl>
<dt><code>wp wc user_membership list</code></dt>
<dd>Outputs a table of default data for all memberships</dd>
<dt><code>wp wc user_membership list --format="csv"</code></dt>
<dd>Provides a CSV formatted result of all user memberships</dd>
<dt><code>wp wc user_membership list --fields="plan_id, status"</code></dt>
<dd>Outputs a list of memberships with only the plan ID and membership status.</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-11">wp wc user_membership import</h3>
<p>Import a csv file of user_memberships to be created or merged:<br />
<code>wp wc user_membership import user_memberships.csv</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>fields_delimiter</td>
<td>string – the field delimiter used in the CSV file, e.g., <code>--fields_delimiter="|"</code></td>
</tr>
<tr>
<td>timezone</td>
<td>string – the timezone in which all dates from imported CSV data are assumed to be (defaults to the current site timezone)</td>
</tr>
<tr>
<td>default_start_date</td>
<td>string – default start date of imported user memberships when a date is not specified from CSV data (defaults to today’s date), e.g., <code>"2018-07-01"</code></td>
</tr>
<tr>
<td>create_new_memberships</td>
<td>string – if new memberships should be created if not found from CSV data, (“yes” or “no”) e.g., <code>--create_new_memberships="yes"</code></td>
</tr>
<tr>
<td>merge_existing_memberships</td>
<td>string – if memberships should be merged when matching data is found from the CSV file, (“yes” or “no”) e.g., <code>--merge_existing_memberships="yes"</code></td>
</tr>
<tr>
<td>allow_memberships_transfer</td>
<td>string – allow transferring user memberships between users if a different owner is specified in CSV data, (“yes” or “no”) e.g., <code>--allow_memberships_transfer="yes"</code></td>
</tr>
<tr>
<td>create_new_users</td>
<td>string – if users should be created from CSV data when no existing user could be found, (“yes” or “no”) e.g., <code>--create_new_users="no"</code></td>
</tr>
<tr>
<td>notify_new_users</td>
<td>string – whether to send email notifications when a new user is created during an import process, (“yes” or “no”) e.g., <code>--notify_new_users="no"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2 id="section-12">Legacy CLI</h2>
<p>Versions prior to 1.13.0 can still use our legacy WP CLI implementation. We would recommend updating any command line tooling to the updated WC REST API implementation where possible, as the following commands are now considered deprecated and will be removed at a later date.</p>
<p>&nbsp;</p>
<h3 id="section-13">wp wc memberships plan</h3>
<p>You can manage plans with <code>wp wc memberships plan</code> subcommands:</p>
<table>
<thead>
<tr>
<th>COMMAND</th>
<th>FUNCTION</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>create</code></td>
<td>Create a new membership plan</td>
</tr>
<tr>
<td><code>delete</code></td>
<td>Delete an existing membership plan</td>
</tr>
<tr>
<td><code>update</code></td>
<td>Update one or more membership plans</td>
</tr>
<tr>
<td><code>get</code></td>
<td>Get a membership plan</td>
</tr>
<tr>
<td><code>list</code></td>
<td>List membership plans</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3 id="section-14">wp wc memberships plan create</h3>
<p>Allows you to create new membership plans.</p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>REQUIRED?</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>yes</td>
<td>string – plan name, e.g., <code>"Silver Plan"</code></td>
</tr>
<tr>
<td>slug</td>
<td>no</td>
<td>string – plan slug, e.g., <code>"silver-plan"</code></td>
</tr>
<tr>
<td>access</td>
<td>no</td>
<td>string – way access is granted, e.g., <code>"signup"</code> (free or signup, purchase, manual-only)</td>
</tr>
<tr>
<td>length</td>
<td>no</td>
<td>string – plan duration (if set-length plan), e.g., <code>"2 months"</code></td>
</tr>
<tr>
<td>product</td>
<td>no</td>
<td>int – comma-separated list of IDs that grant access, e.g., <code>123,409,8392</code></td>
</tr>
<tr>
<td>start_date</td>
<td>no</td>
<td>string &#8211; start date for membership (fixed dates), e.g., <code>"2017-01-01"</code></td>
</tr>
<tr>
<td>end_date</td>
<td>no</td>
<td>string &#8211; end date for membership (fixed dates), e.g., <code>"2017-12-31"</code></td>
</tr>
<tr>
<td>status</td>
<td>no</td>
<td>string &#8211; plan post status, e.g., <code>"draft"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="plan-create-examples">Plan create examples</h4>
<dl>
<dt><code>wp wc memberships plan create --name="Gold Membership"</code></dt>
<dd>Creates an admin-assign only, unlimited plan named &#8220;Gold Membership&#8221;</dd>
<dt><code>wp wc memberships plan create --name="Silver" --slug="silver-plan" --length="1 month" --product=123,456,6780</code></dt>
<dd>Create a &#8220;Silver&#8221; plan that lasts 1 month, and grants access via purchase of products 123, 456, or 6780</dd>
<dt><code>wp wc memberships plan create --name="Bronze Plan" --start_date="2017-10-01" --end_date="2018-08-25"</code></dt>
<dd>Create a &#8220;Bronze Plan&#8221; that is accessed via admin assign only, and runs from Oct 1, 2017 to August 25, 2018</dd>
<dt><code>wp wc memberships plan create --name="Free Plan" --access="free"</code></dt>
<dd>Create a &#8220;Free Plan&#8221; that grants access upon registration and is unlimited in length.</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-15">wp wc memberships plan delete</h3>
<p>Deletes a membership plan using ID:<br />
<code>wp wc memberships plan delete 123</code></p>
<p>You can also delete all plans at once:<br />
<code>wp wc memberships plan delete $(wp wc memberships plan list --format=ids)</code></p>
<p>&nbsp;</p>
<h3 id="section-16">wp wc memberships plan update</h3>
<p>Allows you to update membership plans using the plan ID:<br />
<code>wp wc memberships plan update 123</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>string &#8211; new plan name, e.g., <code>"Silver Plan"</code></td>
</tr>
<tr>
<td>slug</td>
<td>string &#8211; new plan slug, e.g., <code>"silver-plan"</code></td>
</tr>
<tr>
<td>access</td>
<td>string &#8211; new access method, e.g., <code>"signup"</code> (free or signup, purchase, manual-only)</td>
</tr>
<tr>
<td>length</td>
<td>string &#8211; new plan duration (set-length plan), e.g., <code>"2 months"</code></td>
</tr>
<tr>
<td>product</td>
<td>int &#8211; comma-separated list of IDs that now grant access, e.g., <code>123,409,8392</code></td>
</tr>
<tr>
<td>start_date</td>
<td>string &#8211; new start date for membership (fixed dates), e.g., <code>"2017-01-01"</code></td>
</tr>
<tr>
<td>end_date</td>
<td>string &#8211; new end date for membership (fixed dates), e.g., <code>"2017-12-31"</code></td>
</tr>
<tr>
<td>status</td>
<td>string &#8211; new plan post status, e.g., <code>"publish"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="plan-update-examples">Plan update examples</h4>
<dl>
<dt><code>wp wc memberships plan update 987 --name="New Name"</code></dt>
<dd>Updates the plan name of membership plan 987</dd>
<dt><code>wp wc memberships plan update 8762 --start_date="2016-01-01" --end_date="2016-12-31"</code></dt>
<dd>Updates the start and end dates of plan 8762</dd>
<dt><code>wp wc memberships plan update 333 --access="signup"</code></dt>
<dd>Changes plan 333 to grant access at registration</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-17">wp wc memberships plan get</h3>
<p>Get data associated with a membership plan by ID:<br />
<code>wp wc memberships plan get 123</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string &#8211; the field to get values for, e.g., <code>--field="members_count"</code> (slug, id, name, type, length, members_count, etc)</td>
</tr>
<tr>
<td>fields</td>
<td>string &#8211; comma-separated list of fields to get values for, e.g., <code>--fields="slug,members_count"</code></td>
</tr>
<tr>
<td>format</td>
<td>string &#8211; the desired format for requested date, e.g., <code>--format="json"</code> (table, json, csv)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="get-plan-examples">Get plan examples</h4>
<dl>
<dt><code>wp wc memberships plan get 246</code></dt>
<dd>Gets all fields for plan 246</dd>
<dt><code>wp wc memberships plan get 343 --fields="id,slug,type,length,members_count"</code></dt>
<dd>Gets a selection of fields for plan 343</dd>
<dt><code>wp wc memberships plan get 8761 --format="json"</code></dt>
<dd>Gets plan data for membership plan 8761 in JSON formation</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-18">wp wc memberships plan list</h3>
<p>Lists data associated with membership plans:<br />
<code>wp wc memberships plan list</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string &#8211; print the value of a single field for all plans, e.g., <code>--field="members_count"</code> (slug, id, name, type, length, product_ids, members_count, status, start_date, end_date)</td>
</tr>
<tr>
<td>fields</td>
<td>string &#8211; comma-separated list of fields to print values for, e.g., <code>--fields="slug,members_count"</code></td>
</tr>
<tr>
<td>format</td>
<td>string &#8211; the desired format for requested date, e.g., <code>--format="json"</code> (table, csv, json, count, ids)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="plan-list-examples">Plan list examples</h4>
<dl>
<dt><code>wp wc memberships plan list</code></dt>
<dd>Outputs a table of default data for all plans</dd>
<dt><code>wp wc memberships plan list --format="csv"</code></dt>
<dd>Provides a CSV formatted result of all membership plans</dd>
<dt><code>wp wc memberships plan list --fields="slug,members_count"</code></dt>
<dd>Outputs a list of plans with only the slug and member count.</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-19">wp wc memberships membership</h3>
<p>You can manage user memberships with <code>wp wc memberships membership</code> subcommands:</p>
<table>
<thead>
<tr>
<th>COMMAND</th>
<th>FUNCTION</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>create</code></td>
<td>Create a new user membership</td>
</tr>
<tr>
<td><code>delete</code></td>
<td>Delete an existing user membership</td>
</tr>
<tr>
<td><code>update</code></td>
<td>Update one or more user memberships</td>
</tr>
<tr>
<td><code>get</code></td>
<td>Get a user membership</td>
</tr>
<tr>
<td><code>list</code></td>
<td>List user memberships</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3 id="section-20">wp wc memberships membership create</h3>
<p>Allows you to create new user membership.</p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>REQUIRED?</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>customer</td>
<td>yes</td>
<td>int &#8211; the user ID for the member, e.g., <code>--customer=22</code></td>
</tr>
<tr>
<td>plan</td>
<td>yes</td>
<td>int|string &#8211; plan ID or slug, e.g., <code>--plan="silver-plan"</code></td>
</tr>
<tr>
<td>order</td>
<td>no</td>
<td>int &#8211; ID of order that granted access, e.g., <code>--order=123</code></td>
</tr>
<tr>
<td>product</td>
<td>no</td>
<td>int &#8211; ID of product that granted access, e.g., <code>--product=46</code></td>
</tr>
<tr>
<td>subscription</td>
<td>no</td>
<td>int &#8211; ID of subscription the membership is tied to, e.g., <code>--subscription=125</code></td>
</tr>
<tr>
<td>status</td>
<td>no</td>
<td>string &#8211; membership status, e.g., <code>--status="paused"</code></td>
</tr>
<tr>
<td>start_date</td>
<td>no</td>
<td>string &#8211; start date for the user membership, e.g., <code>"2017-01-01"</code></td>
</tr>
<tr>
<td>end_date</td>
<td>no</td>
<td>string &#8211; end date for the user membership, e.g., <code>"2017-12-31"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="membership-creation-examples">Membership creation examples</h4>
<dl>
<dt><code>wp wc memberships membership create --customer=83 --plan=238</code></dt>
<dd>Creates an unlimited membership for user 83 to plan 238</dd>
<dt><code>wp wc memberships membership create --customer=101 --plan="silver" --start_date="2016-01-01" --end_date="2016-06-30" --status="expired"</code></dt>
<dd>Creates an expired silver membership for user 101 that started on Jan 1, 2016, and ended on June 30, 2016</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-21">wp wc memberships membership delete</h3>
<p>Deletes a user membership using ID:<br />
<code>wp wc memberships membership delete 101</code></p>
<p>You can also delete all members at once:<br />
<code>wp wc memberships membership delete $(wp wc memberships membership list --format=ids)</code></p>
<p>&nbsp;</p>
<h3 id="section-22">wp wc memberships membership update</h3>
<p>Allows you to update user memberships using the user membership ID:<br />
<code>wp wc memberships membership update 9809</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>customer</td>
<td>int &#8211; transfer the membership to a new user, <code>--customer=296</code></td>
</tr>
<tr>
<td>plan</td>
<td>int|string &#8211; new plan plan ID or slug, e.g., <code>--plan="gold-plan"</code></td>
</tr>
<tr>
<td>order</td>
<td>int &#8211; updated ID of order that granted access, e.g., <code>--order=236</code></td>
</tr>
<tr>
<td>product</td>
<td>int &#8211; updated ID of product that granted access, e.g., <code>--product=502</code></td>
</tr>
<tr>
<td>subscription</td>
<td>int &#8211; updated ID of subscription the membership is tied to, e.g., <code>--subscription=9862</code></td>
</tr>
<tr>
<td>status</td>
<td>string &#8211; updated membership status, e.g., <code>--status="cancelled"</code></td>
</tr>
<tr>
<td>start_date</td>
<td>string &#8211; updated start date for the user membership, e.g., <code>"2017-07-01"</code></td>
</tr>
<tr>
<td>end_date</td>
<td>string &#8211; updated end date for the user membership, e.g., <code>"2018-07-01"</code></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="membership-update-examples">Membership update examples</h4>
<dl>
<dt><code>wp wc memberships membership update 232 --customer=876</code></dt>
<dd>Transfers user membership 232 to user 876</dd>
<dt><code>wp wc memberships membership update 8762 --end_date="2017-01-01" --status="active"</code></dt>
<dd>Updates the end date and status of user membership 8762</dd>
<dt><code>wp wc memberships membership update 776 --plan=126</code></dt>
<dd>Changes user membership 776 to use plan 126</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-23">wp wc memberships membership get</h3>
<p>Get data associated with a user membership by ID:<br />
<code>wp wc memberships membership get 653</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string &#8211; the field to get values for, e.g., <code>--field="status"</code> (id, user_id, plan_id, plan, status, start_date, end_date)</td>
</tr>
<tr>
<td>fields</td>
<td>string &#8211; comma-separated list of fields to get values for, e.g., <code>--fields="plan,status"</code></td>
</tr>
<tr>
<td>format</td>
<td>string &#8211; the desired format for requested date, e.g., <code>--format="json"</code> (table, json, csv)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="get-membership-examples">Get membership examples</h4>
<dl>
<dt><code>wp wc memberships membership get 848</code></dt>
<dd>Gets all fields for user membership 848</dd>
<dt><code>wp wc memberships membership get 848 --fields="plan,status"</code></dt>
<dd>Gets the plan and status for user membership 848</dd>
<dt><code>wp wc memberships membership get 848 --format="json"</code></dt>
<dd>Gets data for user membership 848 in JSON formation</dd>
</dl>
<p>&nbsp;</p>
<h3 id="section-24">wp wc memberships membership list</h3>
<p>Lists data associated with all user memberships:<br />
<code>wp wc memberships membership list</code></p>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>VALUES</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>string &#8211; print the value of a single field for all memberships, e.g., <code>--field="user_id"</code> (id, user_id, plan_id, plan, status, start_date, end_date, subscription)</td>
</tr>
<tr>
<td>fields</td>
<td>string &#8211; comma-separated list of fields to print values for, e.g., <code>--fields="plan,status"</code></td>
</tr>
<tr>
<td>format</td>
<td>string &#8211; the desired format for requested date, e.g., <code>--format="json"</code> (table, csv, json, count, ids)</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4 id="user-membership-list-examples">User membership list examples</h4>
<dl>
<dt><code>wp wc memberships memberships list</code></dt>
<dd>Outputs a table of default data for all memberships</dd>
<dt><code>wp wc memberships memberships list --format="csv"</code></dt>
<dd>Provides a CSV formatted result of all user memberships</dd>
<dt><code>wp wc memberships memberships list --fields="plan_id, status"</code></dt>
<dd>Outputs a list of memberships with only the plan ID and membership status.</dd>
</dl>
<p>&nbsp;</p>
<h2 id="section-25">CLI Extensions</h2>
<p>Here&#8217;s a helpful community plugin to replicate the CSV Import functionality of Memberships via the command line. This is a nifty tool for developers to allow them to import memberships via the command line without timeouts, helpful for large data sets.</p>
<h2 id="questions-and-support">Questions &amp; Support</h2>
<p>Looking for questions or support? You can submit a request right from your account</p><p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-cli-reference/">WooCommerce Memberships – CLI Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/woocommerce-memberships-cli-reference/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WooCommerce Memberships Admin Hook Reference</title>
		<link>https://help.codibu.com/blog/woocommerce-memberships-admin-hook-reference/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=woocommerce-memberships-admin-hook-reference</link>
					<comments>https://help.codibu.com/blog/woocommerce-memberships-admin-hook-reference/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sat, 07 Nov 2020 12:48:08 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/woocommerce-memberships-admin-hook-reference/</guid>

					<description><![CDATA[<p>For Developers: Admin Hook Reference This document covers all admin-specific hooks in WooCommerce Memberships. You can also view the document on frontend-specific hooks. WooCommerce Memberships is extremely extensible<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-admin-hook-reference/">WooCommerce Memberships Admin Hook Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="entry">
<h2 id="overview">For Developers: Admin Hook Reference</h2>
<div class="woo-sc-box info   ">This document covers all admin-specific hooks in WooCommerce Memberships. You can also view the document on <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-frontend-hook-reference/">frontend-specific hooks</a>.</div>
<p><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">WooCommerce Memberships</a> is extremely extensible and offers ample actions and filters for developers to customize it as needed. If a hook doesn’t exist where you think it should, please submit a ticket so we can consider its addition.</p>
<p>This hook reference includes some of the actions and filters developers may find useful while customizing the plugin, but is not an exhaustive reference of all plugin hooks. Inline docs include parameters and returned values for more detail — the appropriate file for each hook is listed so you can refer to it.</p>
<div class="woo-sc-box note   ">Please note that this document is a developer reference provided as a courtesy, as our support policy does not include customizations.</p>
<p>&nbsp;</p>
<p>This reference lists helpful filters / actions and is meant to be a directory. Please see the plugin’s inline documentation for additional details on parameters, returned values, and usage.</p>
</div>
<p>&nbsp;</p>
<h2 id="section-2">Filters: Membership Access</h2>
<h4 id="wc_memberships_access_granting_purchased_product_id">wc_memberships_access_granting_purchased_product_id</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $product_id the ID that’s used for access</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $access_granting_product_ids Array of product IDs that can grant access to this plan</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_Membership_Plan $plan Membership plan access will be granted to</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>int – the new product ID to use</dd>
</dl>
<p>Multiple products from a single order can grant access to a membership plan. Default behavior is to use the first product that grants access, but this can be overridden using this filter.</p>
<h4 id="wc_memberships_grant_access_from_new_purchase">wc_memberships_grant_access_from_new_purchase</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.3.5</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $grant_access true by default</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args {</p>
<p>&nbsp;</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>@type int|string $user_id user ID for order</li>
<li>@type int|string $product_id product ID that grants access</li>
<li>@type int|string $order_id order ID</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<p>Filters whether membership access should be granted from the current purchase or not. Default behavior is to always grant access if a membership product is purchased.</p>
<p>Examples:</p>
<ul>
<li>Disable granting access if the customer already holds any membership</li>
<li>Disable granting access if the customer already holds an active membership</li>
</ul>
<h4 id="wc_memberships_plan_grants_access_while_subscription_active">wc_memberships_plan_grants_access_while_subscription_active</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.6.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $grants_access Default: true</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $plan_id Membership Plan ID</dd>
</dl>
<p>Filter whether a plan grants access to a membership while subscription is active.</p>
<h4 id="wc_memberships_grant_access_from_existing_purchase_order_statuses">wc_memberships_grant_access_from_existing_purchase_order_statuses</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $valid_order_statuses_for_grant array of order statuses</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>object $plan the associated membership plan object</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – the updated array of status</dd>
</dl>
<p>Filter the array of valid order statuses that grant access from previous purchases when the admin uses the “grant previous purchases access” action. Defaults to ‘processing’ and ‘completed’.</p>
<p>Example to add “Shipped” and “Invoice Paid” orders (You could also use these statuses for access during the purchasing cycle in addition to processing and completed orders, which the second function covers):</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Membership access is already granted when orders are processing or completed
 * Add membership access for custom order statuses as well
 *
 * Example: grant membership access for "Shipped" and "Invoice Paid" orders during purchase cycle as well
 * Use the appropriate action for your custom order status
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_grant_access_for_custom_order_statuses</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="com">// bail if Memberships is not active</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> function_exists</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'woocommerce_order_status_shipped'</span><span class="pun">,</span><span class="pln"> array</span><span class="pun">(</span><span class="pln"> wc_memberships</span><span class="pun">()-&gt;</span><span class="pln">get_plans_instance</span><span class="pun">(),</span><span class="pln"> </span><span class="str">'grant_access_to_membership_from_order'</span><span class="pln"> </span><span class="pun">),</span><span class="pln"> </span><span class="lit">11</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
                add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'woocommerce_order_status_invoice-paid'</span><span class="pun">,</span><span class="pln"> array</span><span class="pun">(</span><span class="pln"> wc_memberships</span><span class="pun">()-&gt;</span><span class="pln">get_plans_instance</span><span class="pun">(),</span><span class="pln"> </span><span class="str">'grant_access_to_membership_from_order'</span><span class="pln"> </span><span class="pun">),</span><span class="pln"> </span><span class="lit">11</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'init'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_grant_access_for_custom_order_statuses'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">15</span><span class="pln"> </span><span class="pun">);</span>
<span class="com">/**
 * Include custom order statuses in the plan "Grant Access" action to
 * create new memberships as well
 *
 * Example: include "Shipped" and "Invoice Paid Orders" in "Grant Access" action for memberships
 * @param array $statuses orders statuses to create memberships for in "Grant access" action
 * @param object $plan the associated membership plan object
 * @return array $statuses the updated array of statuses for which to grant access
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_add_grant_access_order_statuses</span><span class="pun">(</span><span class="pln"> $statuses</span><span class="pun">,</span><span class="pln"> $plan </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="com">// Grant membership access to "Shipped" and "Invoice Paid" orders as well</span><span class="pln">
        </span><span class="com">// when "Grant Access" action is used</span><span class="pln">
        $statuses </span><span class="pun">=</span><span class="pln"> array_merge</span><span class="pun">(</span><span class="pln"> $statuses</span><span class="pun">,</span><span class="pln"> array</span><span class="pun">(</span><span class="pln"> </span><span class="str">'shipped'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'invoice-paid'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> $statuses</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_grant_access_from_existing_purchase_order_statuses'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_add_grant_access_order_statuses'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">10</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">view rawwoocommerce-memberships/admin/grant-membership-access-for-custom-order-statuses.php</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_allow_cumulative_member_discounts">wc_memberships_allow_cumulative_member_discounts</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.7.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $cumulative true if discounts should stack across plans</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $member_id ID for the member / WP user</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Product $product</dd>
</dl>
<p>Filters whether discounts should stack if a member has more than one member discount for a product. Return false to disable stacking:</p>
<pre>add_filter( 'wc_memberships_allow_cumulative_member_discounts', '__return_false' );</pre>
<p>&nbsp;</p>
<h2 id="section-3">Filters: Membership Statuses</h2>
<h4 id="wc_memberships_user_membership_statuses">wc_memberships_user_membership_statuses</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $statuses Associative array of statuses</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated status array</dd>
</dl>
<p>Passes in an associative array of all user membership statuses, which can be used to add custom user membership statuses.</p>
<p>Example to add new statuses:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Add custom user membership statuses
 *
 * @param array $statuses the array of membership statuses
 * @return array $statuses the updated status array
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_add_membership_statuses</span><span class="pun">(</span><span class="pln"> $statuses </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        $new_statuses </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">(</span><span class="pln">
                </span><span class="str">'wcm-refunded'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> array</span><span class="pun">(</span><span class="pln">
                        </span><span class="str">'label'</span><span class="pln">       </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="str">'Refunded'</span><span class="pun">,</span><span class="pln">
                        </span><span class="str">'label_count'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> _n_noop</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Refunded &lt;span class="count"&gt;(%s)&lt;/span&gt;'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Refunded &lt;span class="count"&gt;(%s)&lt;/span&gt;'</span><span class="pln"> </span><span class="pun">),</span><span class="pln">
                </span><span class="pun">),</span><span class="pln">

                </span><span class="str">'wcm-some-status'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> array</span><span class="pun">(</span><span class="pln">
                        </span><span class="str">'label'</span><span class="pln">       </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="str">'Another Status'</span><span class="pun">,</span><span class="pln">
                        </span><span class="str">'label_count'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> _n_noop</span><span class="pun">(</span><span class="pln"> </span><span class="str">'SomeStatus &lt;span class="count"&gt;(%s)&lt;/span&gt;'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'SomeStatus &lt;span class="count"&gt;(%s)&lt;/span&gt;'</span><span class="pln"> </span><span class="pun">),</span><span class="pln">
                </span><span class="pun">),</span><span class="pln">
        </span><span class="pun">);</span><span class="pln">

        $statuses </span><span class="pun">=</span><span class="pln"> array_merge</span><span class="pun">(</span><span class="pln"> $statuses</span><span class="pun">,</span><span class="pln"> $new_statuses </span><span class="pun">);</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> $statuses</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_user_membership_statuses'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_add_membership_statuses'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">view rawwoocommerce-memberships/admin/add-membership-status.php</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_active_access_membership_statuses">wc_memberships_active_access_membership_statuses</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.7.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $statuses array of statuses valid for content access</dd>
</dl>
<p>Filters the user memberships status that will give the customer access to restricted content.</p>
<h4 id="wc_memberships_valid_membership_statuses_for_cancel">wc_memberships_valid_membership_statuses_for_cancel</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $statuses Array of statuses valid for cancellation</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated array of statuses</dd>
</dl>
<p>Filters the user membership statuses that can be cancelled by the customer.</p>
<h4 id="wc_memberships_valid_membership_statuses_for_renewal">wc_memberships_valid_membership_statuses_for_renewal</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $statuses Array of statuses valid for renewal</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated array of statuses</dd>
</dl>
<p>Filters the user membership statuses that can be renewed by the customer.</p>
<h4 id="wc_memberships_bulk_edit_user_memberships_status_options">wc_memberships_bulk_edit_user_memberships_status_options</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $statuses Array of bulk-edit statuses available</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated array of statuses</dd>
</dl>
<p>Filter the status options available in user memberships bulk edit box.</p>
<p>&nbsp;</p>
<h2 id="section-4">Filters: Settings</h2>
<h4 id="wc_memberships_general_settings">wc_memberships_general_settings</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $settings Array of the plugin settings</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated settings array</dd>
</dl>
<p>Filters the Memberships &gt; General Settings.</p>
<h4 id="wc_memberships_products_settings">wc_memberships_products_settings</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $settings Array of the plugin settings</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated settings array</dd>
</dl>
<p>Filters the Memberships &gt; Products Settings.</p>
<p>&nbsp;</p>
<h2 id="section-5">Filters: Excluded from Restriction</h2>
<h4 id="wc_memberships_content_restriction_excluded_post_types">wc_memberships_content_restriction_excluded_post_types</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $post_types List of post types to exclude</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – the updated array of post types</dd>
</dl>
<p>Creates a blacklist to exclude post types from content restriction content type options. Helpful if CPTs are added from other plugins that shouldn’t be available in content restriction rules.</p>
<p>Example to remove Sensei Messages from posts that can be restricted:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Remove post types from the membership plan restriction options
 * Example: remove Sensei Messages from post types that can be restricted
 *
 * @param array $blacklist the array of post types to exclude from restriction options
 * @return array $blacklist the updated array of post types to exclude
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_add_post_type_to_blacklist</span><span class="pun">(</span><span class="pln"> $blacklist </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        $blacklist</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">'sensei_message'</span><span class="pun">;</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> $blacklist</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_content_restriction_excluded_post_types'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_add_post_type_to_blacklist'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">view rawwoocommerce-memberships/admin/exclude-post-type-from-content-restriction-options.php</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_rule_type_excluded_taxonomies">wc_memberships_{$rule_type}_excluded_taxonomies</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $taxonomies List of taxonomies to exclude</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated taxonomy list</dd>
</dl>
<p>Excludes taxonomies from restriction rules. Rule type can be <code>content_restriction</code>, <code>product_restriction</code>, or <code>purchasing_discount</code>.</p>
<p>&nbsp;</p>
<h2 id="section-6">Filters: Meta Boxes</h2>
<h4 id="wc_memberships_product_data_tabs">wc_memberships_product_data_tabs</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $tabs Associative array of memberships data tabs</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated tab array</dd>
</dl>
<p>Filters product memberships data tabs in the Membership meta box to add or remove tabs.</p>
<h4 id="wc_membership_plan_data_tabs">wc_membership_plan_data_tabs</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $tabs Associative array of membership plan tabs</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array – updated tab array</dd>
</dl>
<p>Filters membership plan data tabs on the edit membership plan pages.</p>
<p>&nbsp;</p>
<h2 id="section-7">Actions: General</h2>
<h4 id="wc_memberships_activated">wc_memberships_activated</h4>
<p>Runs when Memberships is activated.</p>
<h4 id="wc_memberships_deactivated">wc_memberships_deactivated</h4>
<p>Runs when Memberships is deactivated.</p>
<h4 id="wc_memberships_duplicate_membership_plan">wc_memberships_duplicate_membership_plan</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $new_id New plan ID</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WP_Post $post Original plan object</dd>
</dl>
<p>Fires after a membership plan has been duplicated.</p>
<p>&nbsp;</p>
<h2 id="section-8">Actions: Edit User Memberships</h2>
<h4 id="wc_memberships_before_user_membership_notes">wc_memberships_before_user_membership_notes</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership</dd>
</dl>
<p>Fires at the beginning of the user membership notes meta box.</p>
<h4 id="wc_memberships_after_user_membership_notes">wc_memberships_after_user_membership_notes</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership</dd>
</dl>
<p>Fires at the end of the user membership notes meta box.</p>
<h4 id="wc_memberships_before_user_membership_member_details">wc_memberships_before_user_membership_member_details</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id The member (user) ID</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_membership_id The post id of the user membership post</dd>
</dl>
<p>Fires at the beginning of the member details meta box.</p>
<h4 id="wc_memberships_after_user_membership_member_details">wc_memberships_after_user_membership_member_details</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id The member (user) ID</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_membership_id The post id of the user membership post</dd>
</dl>
<p>Fires at the end of the member details meta box.</p>
<h4 id="wc_memberships_before_user_membership_details">wc_memberships_before_user_membership_details</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership</dd>
</dl>
<p>Fires before the membership details in edit user membership screen.</p>
<h4 id="wc_memberships_after_user_membership_details">wc_memberships_after_user_membership_details</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership</dd>
</dl>
<p>Fires after the membership details in edit user membership screen.</p>
<h4 id="wc_memberships_before_user_membership_billing_details">wc_memberships_before_user_membership_billing_details</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership</dd>
</dl>
<p>Fires before the billing details in edit user membership screen.</p>
<h4 id="wc_memberships_after_user_membership_billing_details">wc_memberships_after_user_membership_billing_details</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership</dd>
</dl>
<p>Fires after the billing details in edit user membership screen.</p>
<h4 id="wc_memberships_user_membership_actions_start">wc_memberships_user_membership_actions_start</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $post_id The post id of the wc_user_membership post</dd>
</dl>
<p>Fires at the start of the user membership actions meta box.</p>
<h4 id="wc_memberships_user_membership_actions_end">wc_memberships_user_membership_actions_end</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $post_id The post id of the wc_user_membership post</dd>
</dl>
<p>Fires at the end of the user membership actions meta box.</p>
<p>&nbsp;</p>
<h2 id="section-9">Actions: Restriction Meta Boxes</h2>
<div class="woo-sc-box normal   ">All restriction meta box actions are located in: <strong>/includes/admin/meta-boxes/class-wc-memberships-meta-box-product-memberships-data.php</strong></div>
<h4 id="wc_memberships_data_product_write_panel_tabs">wc_memberships_data_product_write_panel_tabs</h4>
<p>Fires after the product memberships data write panel tabs are displayed.</p>
<h4 id="wc_memberships_data_options_restrict_product">wc_memberships_data_options_restrict_product</h4>
<p>Fires after the product memberships data product restriction panel is displayed.</p>
<h4 id="wc_memberships_data_options_grant_access">wc_memberships_data_options_grant_access</h4>
<p>Fires after the product memberships data grant access panel is displayed.</p>
<h4 id="wc_memberships_data_options_purchasing_discounts">wc_memberships_data_options_purchasing_discounts</h4>
<p>Fires after the membership plan purchasing discounts panel is displayed.</p>
<h4 id="wc_memberships_data_product_panels">wc_memberships_data_product_panels</h4>
<p>Fires after the product memberships data panels are displayed.</p>
<p>&nbsp;</p>
<h2 id="section-10">Actions: Edit Membership Plan</h2>
<div class="woo-sc-box normal   ">All membership plan page actions are located in: <strong>/includes/admin/meta-boxes/class-wc-memberships-meta-box-membership-plan-data.php</strong></div>
<h4 id="wc_membership_plan_write_panel_tabs">wc_membership_plan_write_panel_tabs</h4>
<p>Fires after the membership plan write panel tabs are displayed.</p>
<h4 id="wc_membership_plan_options_membership_plan_data_general">wc_membership_plan_options_membership_plan_data_general</h4>
<p>Fires after the membership plan general data panel is displayed.</p>
<h4 id="wc_membership_plan_options_membership_plan_data_restrict_content">wc_membership_plan_options_membership_plan_data_restrict_content</h4>
<p>Fires after the membership plan content restriction panel is displayed.</p>
<h4 id="wc_membership_plan_options_membership_plan_data_restrict_products">wc_membership_plan_options_membership_plan_data_restrict_products</h4>
<p>Fires after the membership plan product restriction panel is displayed.</p>
<h4 id="wc_membership_plan_options_membership_plan_data_purchasing_discounts">wc_membership_plan_options_membership_plan_data_purchasing_discounts</h4>
<p>Fires after the membership plan purchasing discounts panel is displayed.</p>
<h4 id="wc_membership_plan_options_membership_plan_members_area">wc_membership_plan_options_membership_plan_members_area</h4>
<p>Fires after the membership plan members area panel is displayed.</p>
<h4 id="wc_membership_plan_data_panels">wc_membership_plan_data_panels</h4>
<p>Fires after the membership plan data panels are displayed.</p>
<p>&nbsp;</p>
<h2 id="section-11">Actions: Membership Lifecycle</h2>
<h4 id="wc_memberships_grant_membership_access_from_purchase">wc_memberships_grant_membership_access_from_purchase</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_Membership_Plan $membership_plan The plan that user was granted access to</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args {</p>
<p>&nbsp;</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>@type int|string $user_id user ID for order</li>
<li>@type int|string $product_id product ID that grants access</li>
<li>@type int|string $order_id order ID</li>
<li>@type int|string $user_membership_id post ID for the new user membership</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<p>Fires after a user has been granted membership access from a purchase.</p>
<h4 id="wc_memberships_user_membership_saved">wc_memberships_user_membership_saved</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.3.8</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>/WC_Memberships_Membership_Plan $membership_plan The plan that user was granted access to</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args {</p>
<p>&nbsp;</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>@type int|string $user_id user ID for the membership</li>
<li>@type int|string $user_membership_id post ID for the new user membership</li>
<li>@type bool $is_update true if the membership is being updated, false if new</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<p>Fires after a user has been granted membership access, either from purchase, from programmatically creating memberships, or from admin action.</p>
<h4 id="wc_memberships_user_membership_created">wc_memberships_user_membership_created</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.3.8</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>/WC_Memberships_Membership_Plan $membership_plan The plan that user was granted access to</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args {</p>
<p>&nbsp;</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>@type int|string $user_id user ID for the membership</li>
<li>@type int|string $user_membership_id post ID for the new user membership</li>
<li>@type bool $is_update true if the membership is being updated, false if new</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<p>Fires after a user has been granted membership access. This action hook is similar to <code>wc_memberships_user_membership_saved</code>, but won’t fire when memberships are manually created from admin.</p>
<h4 id="wc_memberships_cancelled_user_membership">wc_memberships_cancelled_user_membership</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_membership_id</dd>
</dl>
<p>Fires right after a user membership has been cancelled by the customer.</p>
<h4 id="wc_memberships_user_membership_status_changed">wc_memberships_user_membership_status_changed</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $old_status Old status, without the wcm- prefix</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $new_status New status, without the wcm- prefix</dd>
</dl>
<p>Fires when user membership status is updated.</p>
<p>Here’s an example of a basic handler to change user roles based on active / inactive membership status.</p>
<h4 id="wc_memberships_new_user_membership_note">wc_memberships_new_user_membership_note</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $data {</p>
<p>&nbsp;</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>@type int|string $user_membership_id post ID for the new user membership</li>
<li>@type object $note the user membership note (comment object) added</li>
<li>@type bool $notify true if the member will be notified</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
</dl>
<p>Fires after a new membership note is added.</p>
<h2 id="section-12">User Documentation</h2>
<p>All done here? <a href="http://docs.woocommerce.com/document/woocommerce-memberships/">Return to documentation overview →</a></p>
</div>
<div class="related-docs docs-listing single">
<h2>Relevant Links</h2>
<ul class="recommended-docs">
<li>
<h4><a href="http://docs.woothemes.com/document/woocommerce-memberships/">Memberships Overview</a></h4>
</li>
<li>
<h4><a href="https://docs.woothemes.com/document/woocommerce-memberships-hook-reference/">Frontend Hooks</a></h4>
</li>
<li>
<h4><a href="http://codex.wordpress.org/Managing_Plugins#Installing_Plugins">Installing Plugins</a></h4>
</li>
<li>
<h4><a href="https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/">Managing WooCommerce.com subscriptions</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/how-to-get-help/">How to Get Help</a></h4>
</li>
</ul>
</div><p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-admin-hook-reference/">WooCommerce Memberships Admin Hook Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/woocommerce-memberships-admin-hook-reference/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WooCommerce Memberships Snippet Samples</title>
		<link>https://help.codibu.com/blog/woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify</link>
					<comments>https://help.codibu.com/blog/woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sat, 07 Nov 2020 12:40:06 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify/</guid>

					<description><![CDATA[<p>Here are some sample snippets helpful for tweaking the functionality of the WooCommerce Memberships plugin. If you’re looking for more details on modifying Memberships or “For Developers” samples,<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify/">WooCommerce Memberships Snippet Samples</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Here are some sample snippets helpful for tweaking the functionality of the <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">WooCommerce Memberships</a> plugin.</p>
<p>If you’re looking for more details on modifying Memberships or “For Developers” samples, please view our developer documentation.</p>
<div class="woo-sc-box note   "><strong>Note that</strong> these snippets are UNSUPPORTED and are provided as a courtesy. We are unable to modify them or implement them on your site. If you’re not sure how to add custom code to your site or you want to modify these snippets, we recommend hiring a <a href="https://help.codibu.com/blog/kb/becoming-a-wooexpert/">WooExpert</a> to assist.</div>
<p>&nbsp;</p>
<h2 id="section-1">Member Area</h2>
<p>&nbsp;</p>
<h3 id="section-2">Remove Cancel action from My Memberships table</h3>
<p>The actions in the “My Memberships” table can be removed if you don’t want to allow your members to manage their own memberships. This snippet removes the “Cancel” action from the “My Memberships” table in the account area.</p>
<p><strong>Note</strong>: Memberships automatically does this for you if a membership is tied to a subscription, forcing cancellation via the billing instead.</p>
<div id="gist25781502" class="gist">
<div class="gist-file">
<div class="gist-data">
<div class="js-gist-file-update-container js-task-list-container file-box">
<div id="file-wc-memberships-remove-action-php" class="file my-2">
<div class="Box-body p-0 blob-wrapper data type-php  ">
<table class="highlight tab-size js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">
<tbody>
<tr>
<td id="file-wc-memberships-remove-action-php-L1" class="blob-num js-line-number" data-line-number="1"> </td>
<td id="file-wc-memberships-remove-action-php-LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-ent">&lt;?php</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L2" class="blob-num js-line-number" data-line-number="2"> </td>
<td id="file-wc-memberships-remove-action-php-LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c">/**</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L3" class="blob-num js-line-number" data-line-number="3"> </td>
<td id="file-wc-memberships-remove-action-php-LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * Only copy the opening php tag if needed</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L4" class="blob-num js-line-number" data-line-number="4"> </td>
<td id="file-wc-memberships-remove-action-php-LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L5" class="blob-num js-line-number" data-line-number="5"> </td>
<td id="file-wc-memberships-remove-action-php-LC5" class="blob-code blob-code-inner js-file-line"><span class="pl-k">function</span> <span class="pl-en">sv_edit_my_memberships_actions</span>( <span class="pl-s1"><span class="pl-c1">$</span>actions</span> ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L6" class="blob-num js-line-number" data-line-number="6"> </td>
<td id="file-wc-memberships-remove-action-php-LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// remove the &#8220;Cancel&#8221; action for members</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L7" class="blob-num js-line-number" data-line-number="7"> </td>
<td id="file-wc-memberships-remove-action-php-LC7" class="blob-code blob-code-inner js-file-line">unset( <span class="pl-s1"><span class="pl-c1">$</span>actions</span>[<span class="pl-s">&#8216;cancel&#8217;</span>] );</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L8" class="blob-num js-line-number" data-line-number="8"> </td>
<td id="file-wc-memberships-remove-action-php-LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>actions</span>;</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L9" class="blob-num js-line-number" data-line-number="9"> </td>
<td id="file-wc-memberships-remove-action-php-LC9" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L10" class="blob-num js-line-number" data-line-number="10"> </td>
<td id="file-wc-memberships-remove-action-php-LC10" class="blob-code blob-code-inner js-file-line"><span class="pl-en">add_filter</span>( <span class="pl-s">&#8216;wc_memberships_members_area_my-memberships_actions&#8217;</span>, <span class="pl-s">&#8216;sv_edit_my_memberships_actions&#8217;</span> );</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-action-php-L11" class="blob-num js-line-number" data-line-number="11"> </td>
<td id="file-wc-memberships-remove-action-php-LC11" class="blob-code blob-code-inner js-file-line"><span class="pl-en">add_filter</span>( <span class="pl-s">&#8216;wc_memberships_members_area_my-membership-details_actions&#8217;</span>, <span class="pl-s">&#8216;sv_edit_my_memberships_actions&#8217;</span> );</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<h3 id="section-3">Remove End Date Column from My Memberships</h3>
<p>Removes the “End Date” column from being displayed for all user memberships.</p>
<div id="gist29226829" class="gist">
<div class="gist-file">
<div class="gist-data">
<div class="js-gist-file-update-container js-task-list-container file-box">
<div id="file-wc-memberships-remove-end-date-column-php" class="file my-2">
<div class="Box-body p-0 blob-wrapper data type-php  ">
<table class="highlight tab-size js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">
<tbody>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L1" class="blob-num js-line-number" data-line-number="1"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-ent">&lt;?php</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L2" class="blob-num js-line-number" data-line-number="2"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Only copy opening php tag if needed</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L3" class="blob-num js-line-number" data-line-number="3"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Remove the &#8220;End Date&#8221; column from the My Memberships table</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L4" class="blob-num js-line-number" data-line-number="4"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-k">function</span> <span class="pl-en">sv_remove_membership_end_date_column</span>( <span class="pl-s1"><span class="pl-c1">$</span>columns</span> ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L5" class="blob-num js-line-number" data-line-number="5"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC5" class="blob-code blob-code-inner js-file-line">unset( <span class="pl-s1"><span class="pl-c1">$</span>columns</span>[<span class="pl-s">&#8216;membership-end-date&#8217;</span>] );</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L6" class="blob-num js-line-number" data-line-number="6"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>columns</span>;</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L7" class="blob-num js-line-number" data-line-number="7"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC7" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-end-date-column-php-L8" class="blob-num js-line-number" data-line-number="8"> </td>
<td id="file-wc-memberships-remove-end-date-column-php-LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-en">add_filter</span>( <span class="pl-s">&#8216;wc_memberships_my_memberships_column_names&#8217;</span>, <span class="pl-s">&#8216;sv_remove_membership_end_date_column&#8217;</span> );</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<h3 id="section-4">Remove Type Column from My Content Area</h3>
<p>The “My Content” section of the Member Area will show the content type (Post, Page, Project, Forum, etc) as this paginated section shows all accessible content (posts, pages, custom post types) on the site. This snippet removes the “Type” column if its display isn’t needed.</p>
<div id="gist29235299" class="gist">
<div class="gist-file">
<div class="gist-data">
<div class="js-gist-file-update-container js-task-list-container file-box">
<div id="file-wc-memberships-member-area-content-remove-type-column-php" class="file my-2">
<div class="Box-body p-0 blob-wrapper data type-php  ">
<table class="highlight tab-size js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">
<tbody>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L1" class="blob-num js-line-number" data-line-number="1"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-ent">&lt;?php</span></td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L2" class="blob-num js-line-number" data-line-number="2"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Only copy opening php tag if needed</span></td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L3" class="blob-num js-line-number" data-line-number="3"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Removes the &#8220;Type&#8221; column from the &#8220;My Content&#8221; section of the member area</span></td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L4" class="blob-num js-line-number" data-line-number="4"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-k">function</span> <span class="pl-en">sv_members_area_content_remove_column</span>( <span class="pl-s1"><span class="pl-c1">$</span>columns</span> ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L5" class="blob-num js-line-number" data-line-number="5"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC5" class="blob-code blob-code-inner js-file-line"> </td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L6" class="blob-num js-line-number" data-line-number="6"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// unset the &#8220;type&#8221; column, which shows post, page, project, etc</span></td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L7" class="blob-num js-line-number" data-line-number="7"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC7" class="blob-code blob-code-inner js-file-line"><span class="pl-k">if</span> ( <span class="pl-en">isset</span>( <span class="pl-s1"><span class="pl-c1">$</span>columns</span>[<span class="pl-s">&#8216;membership-content-type&#8217;</span>] ) ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L8" class="blob-num js-line-number" data-line-number="8"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC8" class="blob-code blob-code-inner js-file-line">unset( <span class="pl-s1"><span class="pl-c1">$</span>columns</span>[<span class="pl-s">&#8216;membership-content-type&#8217;</span>] );</td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L9" class="blob-num js-line-number" data-line-number="9"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC9" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L10" class="blob-num js-line-number" data-line-number="10"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC10" class="blob-code blob-code-inner js-file-line"> </td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L11" class="blob-num js-line-number" data-line-number="11"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC11" class="blob-code blob-code-inner js-file-line"><span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>columns</span>;</td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L12" class="blob-num js-line-number" data-line-number="12"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC12" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-L13" class="blob-num js-line-number" data-line-number="13"> </td>
<td id="file-wc-memberships-member-area-content-remove-type-column-php-LC13" class="blob-code blob-code-inner js-file-line"><span class="pl-en">add_filter</span>( <span class="pl-s">&#8216;wc_memberships_members_area_my_membership_content_column_names&#8217;</span>, <span class="pl-s">&#8216;sv_members_area_content_remove_column&#8217;</span> );</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<h3 id="section-5">Remove Description Column from My Products Area</h3>
<p>The paginated “My Products” section of the Member Area will show all accessible products for the member (those the plan grants viewing / purchasing for). This snippet removes the “Description” / Excerpt column if its display isn’t needed.</p>
<div id="gist29992478" class="gist">
<div class="gist-file">
<div class="gist-data">
<div class="js-gist-file-update-container js-task-list-container file-box">
<div id="file-wc-memberships-remove-my-products-excerpt-column-php" class="file my-2">
<div class="Box-body p-0 blob-wrapper data type-php  ">
<table class="highlight tab-size js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">
<tbody>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L1" class="blob-num js-line-number" data-line-number="1"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-ent">&lt;?php</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L2" class="blob-num js-line-number" data-line-number="2"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Only copy opening php if needed</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L3" class="blob-num js-line-number" data-line-number="3"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Removes the product short description / excerpt column from &#8220;My Products&#8221;</span></td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L4" class="blob-num js-line-number" data-line-number="4"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-k">function</span> <span class="pl-en">sv_members_area_products_table_columns</span>( <span class="pl-s1"><span class="pl-c1">$</span>columns</span> ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L5" class="blob-num js-line-number" data-line-number="5"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC5" class="blob-code blob-code-inner js-file-line"><span class="pl-k">if</span> ( <span class="pl-en">isset</span>( <span class="pl-s1"><span class="pl-c1">$</span>columns</span>[<span class="pl-s">&#8216;membership-product-excerpt&#8217;</span>] ) ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L6" class="blob-num js-line-number" data-line-number="6"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC6" class="blob-code blob-code-inner js-file-line">unset( <span class="pl-s1"><span class="pl-c1">$</span>columns</span>[<span class="pl-s">&#8216;membership-product-excerpt&#8217;</span>] );</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L7" class="blob-num js-line-number" data-line-number="7"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC7" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L8" class="blob-num js-line-number" data-line-number="8"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>columns</span>;</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L9" class="blob-num js-line-number" data-line-number="9"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC9" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-L10" class="blob-num js-line-number" data-line-number="10"> </td>
<td id="file-wc-memberships-remove-my-products-excerpt-column-php-LC10" class="blob-code blob-code-inner js-file-line"><span class="pl-en">add_filter</span>(<span class="pl-s">&#8216;wc_memberships_members_area_my_membership_products_column_names&#8217;</span>, <span class="pl-s">&#8216;sv_members_area_products_table_columns&#8217;</span>, <span class="pl-c1">10</span>, <span class="pl-c1">1</span> );</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<h2 id="blog-and-posts">Blog &amp; Posts</h2>
<h3 id="section-7">Show Lock Icon on Restricted Posts</h3>
<p>This snippet <strong>requires your site to have loaded FontAwesome</strong> already, as it uses the FontAwesome lock icon. It will show a lock next to the title of any post the member does not have access to yet, or any restricted posts for non-members.</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy if needed</span>
<span class="com">/**
 * Display a FontAwesome lock icon next to the post title if a member does not have access
 *  with WooCommerce Memberships.
 *
 * REQUIRES FontAwesome to be loaded already
 *
 * @param string $post_title the post title
 * @param int $post_id the WordPress post ID
 * @return string the updated title
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_add_post_lock_icon</span><span class="pun">(</span><span class="pln"> $title</span><span class="pun">,</span><span class="pln"> $post_id </span><span class="pun">)</span> <span class="pun">{</span><span class="pln">

        </span><span class="kwd">if</span> <span class="pun">(</span><span class="pln"> is_admin</span><span class="pun">()</span> <span class="pun">)</span> <span class="pun">{</span><span class="pln">
                </span><span class="kwd">return</span><span class="pln"> $title</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="com">// show the lock icon if the post is restricted, or access is delayed</span><span class="pln">
        </span><span class="kwd">if</span> <span class="pun">(</span><span class="pln">   </span><span class="pun">!</span><span class="pln"> current_user_can</span><span class="pun">(</span> <span class="str">'wc_memberships_view_delayed_post_content'</span><span class="pun">,</span><span class="pln">    $post_id </span><span class="pun">)</span><span class="pln">
            </span><span class="pun">||</span> <span class="pun">!</span><span class="pln"> current_user_can</span><span class="pun">(</span> <span class="str">'wc_memberships_view_restricted_post_content'</span><span class="pun">,</span><span class="pln"> $post_id </span><span class="pun">)</span> <span class="pun">)</span> <span class="pun">{</span><span class="pln">

                $title </span><span class="pun">=</span> <span class="str">"&lt;i class='fa fa-lock' aria-hidden='true'&gt;&lt;/i&gt; {$title}"</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="kwd">return</span><span class="pln"> $title</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span> <span class="str">'the_title'</span><span class="pun">,</span> <span class="str">'sv_wc_memberships_add_post_lock_icon'</span><span class="pun">,</span> <span class="lit">10</span><span class="pun">,</span> <span class="lit">2</span> <span class="pun">);</span></pre>
</div>
<div class="gist-meta"> </div>
</div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2 id="section-8">Shop Pages</h2>
<p>&nbsp;</p>
<h3 id="section-9">Remove Member Discount Badges</h3>
<p>The member discount badge’s HTML is filterable, and therefore it can be removed completely using this snippet:</p>
<pre>add_filter( 'wc_memberships_member_discount_badge', '__return_empty_string' );</pre>
<p>&nbsp;</p>
<h3 id="section-10">Disable Discount Stacking</h3>
<p>By default, Memberships will assume that members should always have all benefits of a membership plan. However, this could potentially result in a member receiving 2 discounts or more on a product if the member has multiple plans with discounts.</p>
<p>If you want to disable this behavior, Memberships can instead choose the best discount only instead of stacking discounts — add this snippet to do so:</p>
<pre>add_filter( 'wc_memberships_allow_cumulative_member_discounts', '__return_false' );</pre>
<h2 id="section-11">Integrations</h2>
<p>&nbsp;</p>
<h3 id="section-12">Add Social Login Buttons to Restriction Messages</h3>
<p>You can add WooCommerce Social Login buttons into the “content restricted” notices to make it easier for members with a linked account to log in.</p>
<p>We do have this on our Memberships / Social Login roadmaps to add support for. Until this happens within the plugins themselves, you could add this code snippet to show login buttons in content restriction notices.</p>
<h2 id="section-13">Other Snippets</h2>
<p>&nbsp;</p>
<h3 id="section-14">Grant Access only from Completed Orders</h3>
<p>By default, Memberships grants access to customers for any processing or completed order on your site since these represent paid orders. If you’d like access to only be granted when an order is ‘completed’, but not while it’s ‘processing’, you can use this snippet:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Removes membership access for processing orders
 * so access is only granted at when orders are complete
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_remove_processing_access</span><span class="pun">()</span> <span class="pun">{</span><span class="pln">

        </span><span class="com">// make sure Memberships is active first</span><span class="pln">
        </span><span class="kwd">if</span> <span class="pun">(</span><span class="pln"> function_exists</span><span class="pun">(</span> <span class="str">'wc_memberships'</span> <span class="pun">)</span> <span class="pun">)</span> <span class="pun">{</span><span class="pln">

                remove_action</span><span class="pun">(</span> <span class="str">'woocommerce_order_status_processing'</span><span class="pun">,</span><span class="pln"> array</span><span class="pun">(</span><span class="pln"> wc_memberships</span><span class="pun">()-&gt;</span><span class="pln">get_plans_instance</span><span class="pun">(),</span> <span class="str">'grant_access_to_membership_from_order'</span> <span class="pun">),</span> <span class="lit">9</span> <span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="com">// Add support for Teams for Memberships but make sure it is active first</span><span class="pln">
        </span><span class="kwd">if</span> <span class="pun">(</span><span class="pln"> function_exists</span><span class="pun">(</span> <span class="str">'wc_memberships_for_teams'</span> <span class="pun">)</span> <span class="pun">)</span> <span class="pun">{</span><span class="pln">

                remove_action</span><span class="pun">(</span> <span class="str">'woocommerce_order_status_processing'</span><span class="pun">,</span><span class="pln"> array</span><span class="pun">(</span><span class="pln"> wc_memberships_for_teams</span><span class="pun">()-&gt;</span><span class="pln">get_orders_instance</span><span class="pun">(),</span> <span class="str">'process_team_actions_for_order'</span> <span class="pun">),</span> <span class="lit">10</span> <span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span> <span class="str">'init'</span><span class="pun">,</span> <span class="str">'sv_wc_memberships_remove_processing_access'</span> <span class="pun">);</span></pre>
</div>
</div>
</div>
<p>&nbsp;</p>
<p>If you want to <em>add statuses</em> (such as custom statuses) that grant access, <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-frontend-hook-reference/#filters-access">our developer documentation</a> can help.</p>
<p>&nbsp;</p>
<h3 id="section-15">Create My Memberships Shortcode</h3>
<p>If you want to output the “My Memberships” table outside of the “My Account” area, you can create a shortcode to do so. Please have a look at this snippet.</p>
<h3 id="section-16">More Snippets</h3>
<p>We keep a collection of team snippets for our plugins in this repository. However, the same policy applies — we cannot support these snippets, assist with implementation, or assist with further customizations.</p>
<h2 id="section-17">Table of Contents</h2>
<p>All done here? <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Return to documentation overview →</a></p>
<hr />
<div class="woo-sc-box note   "><strong>Note that</strong> these snippets are UNSUPPORTED and are provided as a courtesy. We are unable to modify them or implement them on your site. If you’re not sure how to add custom code to your site or you want to modify these snippets, we recommend hiring an <a href="https://woocommerce.com/experts/">Woo Expert</a> to assist.</div><p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify/">WooCommerce Memberships Snippet Samples</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/woocommerce-memberships-snippet-sampleshere-are-some-sample-snippets-helpful-for-tweaking-the-functionality-of-the-woocommerce-memberships-plugin-if-youre-looking-for-more-details-on-modify/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WooCommerce Memberships Data Structure</title>
		<link>https://help.codibu.com/blog/woocommerce-memberships-data-structure/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=woocommerce-memberships-data-structure</link>
					<comments>https://help.codibu.com/blog/woocommerce-memberships-data-structure/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sat, 07 Nov 2020 12:31:51 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/woocommerce-memberships-data-structure/</guid>

					<description><![CDATA[<p>Overview WooCommerce Memberships is a large and complex plugin, but we’ve built it with the aim of being extensible and developer-friendly. This is an overview of how<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-data-structure/">WooCommerce Memberships Data Structure</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="entry">
<h2 id="section-1">Overview</h2>
<p><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">WooCommerce Memberships</a> is a large and complex plugin, but we’ve built it with the aim of being extensible and developer-friendly. This is an overview of how data is stored in the Memberships plugin, which can be accessed via WordPress core methods, WooCommerce methods, or via methods within the plugin.</p>
<p>Our <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-frontend-hook-reference/">frontend hook reference</a>, <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-frontend-hook-reference/">admin hook reference</a>, and <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-function-reference/">function / conditional check reference</a> are useful for specific filters, actions, checks, or global functions that will help you while extending Memberships, while this guide provides basic insight into how data is stored.</p>
<p>&nbsp;</p>
<h2 id="section-2">Membership plans</h2>
<p>Membership plans are stored as a <strong>custom post type</strong>: <code>wc_membership_plan</code></p>
<p>Each plan is a post within this post type, so you can easily query all available plans using WordPress core functions, such as <code>get_posts()</code>.</p>
<p>Some pieces of plan data are stored as post meta for the plan’s post, and you can also easily add your own meta for customizations with WP functions. Here are a few meta key / values of interest:</p>
<table>
<thead>
<tr>
<th>META KEY</th>
<th>DATA TYPE</th>
<th>STORED VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>_product_ids</td>
<td>serialized array</td>
<td>product IDs that grant access to the plan</td>
</tr>
<tr>
<td>_access_length</td>
<td>string</td>
<td>length of access (ie 1 years); not set for unlimited memberships</td>
</tr>
<tr>
<td>_members_area_sections</td>
<td>serialized array</td>
<td>enabled member area sections for the plan</td>
</tr>
</tbody>
</table>
<p>Even though plans each contain restriction rules, these rules are not stored as part of the plan’s post meta, and are stored together as an option.</p>
<p>&nbsp;</p>
<h2 id="section-3">Restriction rules</h2>
<p>Restriction and discount rules are stored as <em>options</em> for performance reasons. Mosts hosts cache options, they’re persistent on each page load, and they can be accessed easily.</p>
<p>Searching for option names that contain <code>wc_memberships</code> in your database will yield all options for both Memberships settings and restriction rules.</p>
<p>&nbsp;</p>
<h2 id="section-4">User memberships</h2>
<p>User memberships are each posts in the <strong>custom post type</strong>: <code>wc_user_membership</code></p>
<p>This is done to prevent dumping all plan details into user meta (which helps to avoid using serialized data, as it’s not easily query-able) and to improve flexibility.</p>
<p>As memberships are posts, you can easily query membership with <code>get_posts()</code>, and can leverage postmeta for custom data.</p>
<p>Each user membership post is a <strong>child post of the associated membership plan</strong>. For example, User 1’s Silver Membership is a child post of the Silver Membership plan.</p>
<p>The member is assigned as the author of the user membership post, and members can be the author of more than one post (which means they can have access to more than one plan). Checking the author of a user membership post will give you the member’s user ID.</p>
<p>The post object contains some membership data, such as the <strong>membership status</strong>, which is the post status. However, rather than using WP method to get this data, a better approach would be to use the user membership data accessors as outlined in our <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-function-reference/">function / conditional check reference</a>.</p>
<p>A quick example: in the case of the membership status, this will return the status name rather than the post status, which includes the <code>wcm-</code> prefix in the slug.</p>
<p>The rest of the plan data is stored as post meta for the user membership post, as post meta and can be accessed, changed, and added easily via WordPress core methods.</p>
<table>
<thead>
<tr>
<th>META KEY</th>
<th>DATA TYPE</th>
<th>STORED VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>_product_id</td>
<td>int</td>
<td>product ID purchased that granted access to the membership</td>
</tr>
<tr>
<td>_order_id</td>
<td>int</td>
<td>order ID in which the membership was purchased</td>
</tr>
<tr>
<td>_start_date</td>
<td>string</td>
<td>the start date of the membership as YYYY-MM-DD hh:mm:ss</td>
</tr>
<tr>
<td>_end_date</td>
<td>string</td>
<td>the end date of the membership as YYYY-MM-DD hh:mm:ss; 0 for an unlimited membership</td>
</tr>
<tr>
<td>_subscription_id</td>
<td>int</td>
<td>if tied to a subscription, this is the ID of the subscription that grants access; not set for memberships purchased via other product types</td>
</tr>
<tr>
<td>_paused_date</td>
<td>string</td>
<td>the date a membership was paused as YYYY-MM-DD hh:mm:ss; removed when the membership is reactivated</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2 id="section-5">Membership notes</h2>
<p>Membership notes are stored as WordPress comments for the user membership post. Their functionality is very similar to WooCommerce order notes. If a comment was sent to the member, then the commentmeta for that comment will have <code>notified</code> set to: <code>1</code></p>
<h2 id="section-6">Table of Contents</h2>
<p>All done here? <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Return to documentation overview →</a></p>
</div>
<div class="related-docs docs-listing single">
<h2>Relevant Links</h2>
<ul class="recommended-docs">
<li>
<h4><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Memberships Overview</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/managing-plugins/">Installing Plugins</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/managing-woocommerce-com-subscriptions/">Managing WooCommerce.com subscriptions</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/how-to-get-help/">How to Get Help</a></h4>
</li>
</ul>
</div><p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-data-structure/">WooCommerce Memberships Data Structure</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/woocommerce-memberships-data-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WooCommerce Memberships Function Reference</title>
		<link>https://help.codibu.com/blog/woocommerce-memberships-function-reference/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=woocommerce-memberships-function-reference</link>
					<comments>https://help.codibu.com/blog/woocommerce-memberships-function-reference/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sat, 07 Nov 2020 12:29:35 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/woocommerce-memberships-function-reference/</guid>

					<description><![CDATA[<p>For Developers: Checks &#38; Functions Please note that this document is a developer reference provided as a courtesy, as our support policy does not include customizations.<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-function-reference/">WooCommerce Memberships Function Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="entry">
<h2 id="overview">For Developers: Checks &amp; Functions</h2>
<div class="woo-sc-box note   ">Please note that this document is a developer reference provided as a courtesy, as our support policy does not include customizations. This reference lists helpful functions and where to find them in the plugin. The plugin’s inline documentation has details on parameters / returned values, as this is meant to be a directory.</div>
<p><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">WooCommerce Memberships</a> provides several methods for checking data on content restriction and user memberships.</p>
<p>This reference includes helpful conditional checks and global functions for Memberships. Conditional checks return bool true or false. For example:</p>
<pre>if ( wc_memberships_is_product_viewing_restricted() ) {
    echo 'MARCO!';
} else {
    echo 'POLO!';
}
</pre>
<p>This would check if viewing the current product is restricted to members or not so we can print a different message on the product page. We can also pass in a product id instead to check for a particular product.</p>
<p>&nbsp;</p>
<h2 id="section-2">Conditional Checks: Products</h2>
<div class="woo-sc-box normal   ">All product conditional checks are located in: <strong>/includes/wc-memberships-template-functions.php</strong></div>
<h4 id="wc_memberships_is_product_viewing_restricted">wc_memberships_is_product_viewing_restricted()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|null $post_id Optional, defaults to current post</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if viewing is restricted</dd>
</dl>
<p>Checks if product viewing is restricted.</p>
<h4 id="wc_memberships_is_product_purchasing_restricted">wc_memberships_is_product_purchasing_restricted()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|null $post_id Optional, defaults to current post</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if purchasing is restricted</dd>
</dl>
<p>Checks if product purchasing is restricted.</p>
<p>Example:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Check if product purchasing is retricted
 * Example: Add a restricted product notice
 * Display a top notice to non-members for members-only products
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_members_only_product_notice</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="com">// bail if Memberships isn't active</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="pun">!</span><span class="pln"> function_exists</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        $user_id </span><span class="pun">=</span><span class="pln"> get_current_user_id</span><span class="pun">();</span><span class="pln">

        </span><span class="com">// Bail if the user is already a silver or gold member</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> wc_memberships_is_user_active_member</span><span class="pun">(</span><span class="pln"> $user_id</span><span class="pun">,</span><span class="pln"> </span><span class="str">'silver'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">||</span><span class="pln"> wc_memberships_is_user_active_member</span><span class="pun">(</span><span class="pln"> $user_id</span><span class="pun">,</span><span class="pln"> </span><span class="str">'gold'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="com">// Add our top notice if purchasing is restricted</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> wc_memberships_is_product_purchasing_restricted</span><span class="pun">()</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                wc_print_notice</span><span class="pun">(</span><span class="pln"> </span><span class="str">'This is a preview! Only silver or gold members can purchase this product.'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'notice'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'woocommerce_before_single_product'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_members_only_product_notice'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta"> </div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_product_has_member_discount">wc_memberships_product_has_member_discount()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|null $product_id Product ID: optional, defaults to current product</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if product has discount</dd>
</dl>
<p>Checks if a member discount is present for the product.</p>
<h4 id="wc_memberships_user_has_member_discount">wc_memberships_user_has_member_discount()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|null $product_id Product ID: optional, defaults to current product</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if current user has discount</dd>
</dl>
<p>Checks if the current user has a member discount on the product.</p>
<p>Example:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Check if a product has a member discount
 * Example: Display a member discount notice
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_member_discount_product_notice</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="com">// bail if Memberships isn't active</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="pun">!</span><span class="pln"> function_exists</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="com">// Set a discount end date</span><span class="pln">
        $discount_ends </span><span class="pun">=</span><span class="pln"> date_i18n</span><span class="pun">(</span><span class="pln"> wc_date_format</span><span class="pun">(),</span><span class="pln"> strtotime</span><span class="pun">(</span><span class="pln"> </span><span class="str">'2015-12-31'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">);</span><span class="pln">

        </span><span class="com">// Add our top notice if the member has a discount</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> wc_memberships_user_has_member_discount</span><span class="pun">()</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                wc_print_notice</span><span class="pun">(</span><span class="pln"> sprintf</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Act fast! Your member discount ends on %s.'</span><span class="pun">,</span><span class="pln"> $discount_ends </span><span class="pun">),</span><span class="pln"> </span><span class="str">'notice'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'woocommerce_before_single_product'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_member_discount_product_notice'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
</div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2 id="section-3">Conditional Checks: Content</h2>
<h4 id="wc_memberships_is_post_content_restricted">wc_memberships_is_post_content_restricted()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|null $post_id Optional, defaults to current post</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if content is restricted</dd>
</dl>
<p>Checks if a post or page is restricted.</p>
<p>&nbsp;</p>
<h2 id="section-4">Conditional Checks: Members</h2>
<div class="woo-sc-box normal   ">Looking to check for <em>any</em> active membership? This tutorial may be helpful.</div>
<h4 id="wc_memberships_is_user_member">wc_memberships_is_user_member()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id Optional, defaults to current user</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|string $membership_plan Membership Plan slug, post object or related post ID</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if user is a member of the plan</dd>
</dl>
<p>Checks if a user is a member for a particular plan.</p>
<h4 id="wc_memberships_is_user_active_member">wc_memberships_is_user_active_member()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id Optional, defaults to current user</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|string $membership_plan Membership Plan slug, post object or related post ID</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>bool true if user is an active member of the plan</dd>
</dl>
<p>Checks if a user is an active member for a particular plan.</p>
<p>Example: display a notice to non-members / inactive members</p>
<p>&nbsp;</p>
<h2 id="section-5">Functions: Restricted Content</h2>
<h4 id="wc_memberships_restrict">wc_memberships_restrict()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $content</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string|int|array $membership_plans Optional: the membership plan or plans to check against; Accepts a plan slug, id, or an array of slugs or IDs. Default: all plans</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $delay</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $exclude_trial</dd>
</dl>
<p>Restrict content to specific membership plans.See the <code>[wcm_restrict]</code> shortcode for an example.</p>
<h4 id="wc_memberships_get_user_access_time">wc_memberships_get_user_access_time</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id User to get access time for</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $target Associative array of content type and content id to access to</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $action Type of access, ‘view’ or ‘purchase’ (products only)</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>bool $gmt Whether to return a UTC timestamp (default false, uses site timezone)</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>int|null Timestamp of start access time</dd>
</dl>
<p>Returns user access start timestamp (in site timezone) for content or a product. Note: for now $target only supports <code>'post' =&gt; id</code> or <code>'product' =&gt; id</code></p>
<p>&nbsp;</p>
<h2 id="section-6">Functions: Membership Plans</h2>
<h4 id="wc_memberships_get_membership_plan">wc_memberships_get_membership_plan()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|string|WC_Memberships_Membership_Plan $membership_plan Post object, ID or slug of the membership plan</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>WC_Memberships_Membership_Plan|false Returns the plan object or false on failure</dd>
</dl>
<p>Main function for returning a membership plan.</p>
<h4 id="wc_memberships_get_membership_plans">wc_memberships_get_membership_plans()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args Optional array of arguments, same as for <a href="https://codex.wordpress.org/Template_Tags/get_posts">get_posts()</a></dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>WC_Memberships_Membership_Plan[]</dd>
</dl>
<p>Main function for returning all available membership plans.</p>
<p>&nbsp;</p>
<h2 id="section-7">Functions: User Memberships</h2>
<div class="woo-sc-box normal   ">Looking to check for <em>any</em> active membership? This tutorial may be helpful.</div>
<h4 id="wc_memberships_get_user_active_memberships">wc_memberships_get_user_active_memberships()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.7.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id WP user ID, defaults to current user</dd>
</dl>
<p>Returns an array of active memberships plan objects; empty if the user is not an active member. Supports statuses added for WooCommerce Subscriptions as well.</p>
<pre>$memberships = wc_memberships_get_user_active_memberships( $user_id );

if ( ! empty( $memberships ) ) {
    // do something for this active member
}
</pre>
<h4 id="wc_memberships_get_user_membership">wc_memberships_get_user_membership()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>mixed $id Optional. Post object or post ID of the user membership, or user ID</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>mixed $plan Optional. Membership Plan slug, post object or related post ID</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>WC_Memberships_User_Membership|false The User Membership or false if not found</dd>
</dl>
<p>Main function for returning a user membership; supports getting user membership by membership ID, Post object, or a combination of the user ID and membership plan id/slug/Post object.</p>
<p>If no $id is provided, defaults to getting the membership for the current user.</p>
<p>Example of getting a new, automatically created membership to then set a membership note:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy if needed</span>
<span class="com">/**
 * IF USING MEMBERSHIPS 1.7+
 * This snippet is likely not needed, you can set up a plan to grant access at registration
 *
 * However, this shows usage of programmatic membership creation for developers.
 */</span>
<span class="com">/**
 * Programmatically create a user membership
 * Example: automatically grant membership access to a plan at WP user registration
 * Requires Memberships 1.3+
 *
 * @param int $user_id the ID of the newly created user
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_user_membership_at_registration</span><span class="pun">(</span><span class="pln"> $user_id </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="com">// bail if Memberships isn't active</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="pun">!</span><span class="pln"> function_exists</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships'</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        $args </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">(</span><span class="pln">
                </span><span class="com">// Enter the ID (post ID) of the plan to grant at registration</span><span class="pln">
                </span><span class="str">'plan_id'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="lit">253</span><span class="pun">,</span><span class="pln">
                </span><span class="str">'user_id'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> $user_id</span><span class="pun">,</span><span class="pln">
        </span><span class="pun">);</span><span class="pln">

        </span><span class="com">// magic!</span><span class="pln">
        wc_memberships_create_user_membership</span><span class="pun">(</span><span class="pln"> $args </span><span class="pun">);</span><span class="pln">

        </span><span class="com">// Optional: get the new membership and add a note so we know how this was registered.</span><span class="pln">
        $user_membership </span><span class="pun">=</span><span class="pln"> wc_memberships_get_user_membership</span><span class="pun">(</span><span class="pln"> $user_id</span><span class="pun">,</span><span class="pln"> $args</span><span class="pun">[</span><span class="str">'plan_id'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        $user_membership</span><span class="pun">-&gt;</span><span class="pln">add_note</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Membership access granted automatically from registration.'</span><span class="pln"> </span><span class="pun">);</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'user_register'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_user_membership_at_registration'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">15</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_get_user_memberships">wc_memberships_get_user_memberships()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int $user_id Optional, defaults to current user</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args Optional arguments</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>WC_Memberships_User_Membership[]|null array of user memberships</dd>
</dl>
<p>With <strong>version 1.4+</strong>, can also pass $args as a second parameter; currently accepts “status” and defaults to “any” status. However, this could be used to query all active memberships:</p>
<pre>// get all active memberships for a user; 
// returns an array of active user membership objects
// or null if no memberships are found
$user_id = get_current_user_id();
$args = array( 
    'status' =&gt; array( 'active', 'complimentary', 'pending' ),
);  
$active_memberships = wc_memberships_get_user_memberships( $user_id, $args );
</pre>
<h4 id="wc_memberships_create_user_membership">wc_memberships_create_user_membership()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.3.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>array $args Array of arguments {</p>
<p>&nbsp;</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>@type int|string $user_membership_id membership / post ID for the membership (used when renewing)</li>
<li>@type int|string $plan_id membership plan / post object ID</li>
<li>@type int|string $user_id user ID for the membership</li>
<li>@type int|string $product_id the ID for the access-granting product</li>
<li>@type int|string $order_id the order in which access is granted</li>
</ul>
</li>
</ul>
<p>}</p>
</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $action Action – either ‘create’ or ‘renew’ — when in doubt, use ‘create’</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>WC_Memberships_User_Membership|WP_Error</dd>
</dl>
<p>Example:</p>
<div id="gist25930330" class="gist">
<div class="gist-file">
<div class="gist-data">
<div class="js-gist-file-update-container js-task-list-container file-box">
<div id="file-wc-memberships-create-member-php" class="file my-2">
<div class="Box-body p-0 blob-wrapper data type-php  ">
<table class="highlight tab-size js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">
<tbody>
<tr>
<td id="file-wc-memberships-create-member-php-L1" class="blob-num js-line-number" data-line-number="1"> </td>
<td id="file-wc-memberships-create-member-php-LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-ent">&lt;?php</span></td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L2" class="blob-num js-line-number" data-line-number="2"> </td>
<td id="file-wc-memberships-create-member-php-LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Automatically grant membership to a plan at registration</span></td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L3" class="blob-num js-line-number" data-line-number="3"> </td>
<td id="file-wc-memberships-create-member-php-LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-k">function</span> <span class="pl-en">sv_add_membership_at_registration</span>( <span class="pl-s1"><span class="pl-c1">$</span>user_id</span> ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L4" class="blob-num js-line-number" data-line-number="4"> </td>
<td id="file-wc-memberships-create-member-php-LC4" class="blob-code blob-code-inner js-file-line"> </td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L5" class="blob-num js-line-number" data-line-number="5"> </td>
<td id="file-wc-memberships-create-member-php-LC5" class="blob-code blob-code-inner js-file-line"><span class="pl-k">if</span> ( ! <span class="pl-en">function_exists</span>( <span class="pl-s">&#8216;wc_memberships&#8217;</span> ) ) {</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L6" class="blob-num js-line-number" data-line-number="6"> </td>
<td id="file-wc-memberships-create-member-php-LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-k">return</span>;</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L7" class="blob-num js-line-number" data-line-number="7"> </td>
<td id="file-wc-memberships-create-member-php-LC7" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L8" class="blob-num js-line-number" data-line-number="8"> </td>
<td id="file-wc-memberships-create-member-php-LC8" class="blob-code blob-code-inner js-file-line"> </td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L9" class="blob-num js-line-number" data-line-number="9"> </td>
<td id="file-wc-memberships-create-member-php-LC9" class="blob-code blob-code-inner js-file-line"><span class="pl-s1"><span class="pl-c1">$</span>args</span> = <span class="pl-en">array</span>(</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L10" class="blob-num js-line-number" data-line-number="10"> </td>
<td id="file-wc-memberships-create-member-php-LC10" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// Enter the ID (post ID) of the plan to grant at registration</span></td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L11" class="blob-num js-line-number" data-line-number="11"> </td>
<td id="file-wc-memberships-create-member-php-LC11" class="blob-code blob-code-inner js-file-line"><span class="pl-s">&#8216;plan_id&#8217;</span> =&gt; <span class="pl-c1">253</span>,</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L12" class="blob-num js-line-number" data-line-number="12"> </td>
<td id="file-wc-memberships-create-member-php-LC12" class="blob-code blob-code-inner js-file-line"><span class="pl-s">&#8216;user_id&#8217;</span> =&gt; <span class="pl-s1"><span class="pl-c1">$</span>user_id</span>,</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L13" class="blob-num js-line-number" data-line-number="13"> </td>
<td id="file-wc-memberships-create-member-php-LC13" class="blob-code blob-code-inner js-file-line">);</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L14" class="blob-num js-line-number" data-line-number="14"> </td>
<td id="file-wc-memberships-create-member-php-LC14" class="blob-code blob-code-inner js-file-line"> </td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L15" class="blob-num js-line-number" data-line-number="15"> </td>
<td id="file-wc-memberships-create-member-php-LC15" class="blob-code blob-code-inner js-file-line"><span class="pl-en">wc_memberships_create_user_membership</span>( <span class="pl-s1"><span class="pl-c1">$</span>args</span> );</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L16" class="blob-num js-line-number" data-line-number="16"> </td>
<td id="file-wc-memberships-create-member-php-LC16" class="blob-code blob-code-inner js-file-line">}</td>
</tr>
<tr>
<td id="file-wc-memberships-create-member-php-L17" class="blob-num js-line-number" data-line-number="17"> </td>
<td id="file-wc-memberships-create-member-php-LC17" class="blob-code blob-code-inner js-file-line"><span class="pl-en">add_action</span>( <span class="pl-s">&#8216;user_register&#8217;</span>, <span class="pl-s">&#8216;sv_add_membership_at_registration&#8217;</span>, <span class="pl-c1">15</span> );</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<h2 id="section-8">Functions: Other Functions</h2>
<h4 id="wc_memberships_get_memberships_from_subscription">wc_memberships_get_memberships_from_subscription()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.6.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string|int|WC_Subscription $subscription A Subscription id, object (or key for Subscriptions &lt; 2.0.0)</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>WC_Memberships_User_Membership[] An array of User Membership objects or empty array if none found</dd>
</dl>
<h4 id="wc_memberships_get_member_product_discount">wc_memberships_get_member_product_discount()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership The user membership object</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|WC_Product $product The product object or id to get discount for</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>string discount value</dd>
</dl>
<p>Returns member discount (string) for a product.</p>
<h4 id="wc_memberships_get_members_area_url">wc_memberships_get_members_area_url()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|WC_Memberships_Membership_Plan $membership_plan Object or id</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>string $member_area_section Optional, which section of the member area to point to</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|string $paged Optional, for paged sections</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>string Unescaped URL</dd>
</dl>
<p>Gets the member area URL for a particular membership plan.</p>
<h4 id="wc_memberships_get_members_area_sections">wc_memberships_get_members_area_sections()</h4>
<dl>
<dt>@since</dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt>@param</dt>
<p> </p>
<dd>int|string $membership_plan Optional: membership plan id for filtering purposes</dd>
<p> </p>
<dt>@return</dt>
<p> </p>
<dd>array of sections</dd>
</dl>
<p>Gets the sections for the member area.</p>
<h2 id="section-9">Table of Contents</h2>
<p>All done here? <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Return to documentation overview →</a></p>
</div>
<div class="related-docs docs-listing single">
<h2>Relevant Links</h2>
<ul class="recommended-docs">
<li>
<h4><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Memberships Overvew</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/managing-plugins/">Installing Plugins</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/managing-woocommerce-com-subscriptions/">Managing WooCommerce.com subscriptions</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/how-to-get-help/">How to Get Help</a></h4>
</li>
</ul>
</div><p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-function-reference/">WooCommerce Memberships Function Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/woocommerce-memberships-function-reference/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WooCommerce Memberships Frontend Hook Reference</title>
		<link>https://help.codibu.com/blog/woocommerce-memberships-frontend-hook-reference/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=woocommerce-memberships-frontend-hook-reference</link>
					<comments>https://help.codibu.com/blog/woocommerce-memberships-frontend-hook-reference/#respond</comments>
		
		<dc:creator><![CDATA[JN C]]></dc:creator>
		<pubDate>Sat, 07 Nov 2020 08:43:13 +0000</pubDate>
				<guid isPermaLink="false">https://help.codibu.com/kb/woocommerce-memberships-frontend-hook-reference/</guid>

					<description><![CDATA[<p>For Developers: Frontend Hook Reference This document covers all frontend-specific hooks in WooCommerce Memberships. You can also view the document on admin-specific hooks. WooCommerce Memberships is extremely extensible<span class="excerpt-hellip"> […]</span></p>
<p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-frontend-hook-reference/">WooCommerce Memberships Frontend Hook Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="entry">
<h2 id="overview">For Developers: Frontend Hook Reference</h2>
<div class="woo-sc-box info   ">This document covers all frontend-specific hooks in WooCommerce Memberships. You can also view the document on <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-admin-hook-reference/">admin-specific hooks</a>.</div>
<p><a href="http://www.woocommerce.com/products/woocommerce-memberships/">WooCommerce Memberships</a> is extremely extensible and offers ample actions and filters for developers to customize it as needed. If a hook doesn’t exist where you think it should, please submit a ticket so we can consider its addition.</p>
<p>This hook reference includes some of the actions and filters developers may find useful while customizing the plugin, but is not an exhaustive reference of all plugin hooks. Inline docs include parameters and returned values for more detail — the appropriate file for each hook is listed so you can refer to it.</p>
<div class="woo-sc-box note   ">Please note that this document is a developer reference provided as a courtesy, as our support policy does not include customizations.<br />
This reference lists helpful filters / actions and is meant to be a directory. Please see the plugin’s inline documentation for additional details on parameters, returned values, and usage.</div>
<p>&nbsp;</p>
<h2 id="section-2">Filters: Member Messages</h2>
<div class="woo-sc-box normal   ">All filters for member messages are located in: <strong>/includes/frontend/class-wc-memberships-frontend.php</strong></div>
<h4 id="wc_memberships_user_membership_cancelled_notice">wc_memberships_user_membership_cancelled_notice</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $notice</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – updated notice</dd>
</dl>
<p>Filter the user cancelled membership message on frontend — defaults to, “Your membership was cancelled.”</p>
<h4 id="wc_memberships_member_login_message">wc_memberships_member_login_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.3.8</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The message text</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated message</dd>
</dl>
<p>Filter the member login notice message. This can be configured under settings as well, but we recommend using the default message and filtering as needed, as by default this message responds to the number of discounted items in the cart.</p>
<p>&nbsp;</p>
<h2 id="section-3">Filters: Restriction Messages</h2>
<div class="woo-sc-box normal   ">All frontend filters are included in: <strong>/includes/frontend/class-wc-memberships-frontend.php</strong></div>
<h4 id="wc_memberships_the_restricted_content">wc_memberships_the_restricted_content</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.6.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $content HTML content displayed for the post</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>bool $restricted Whether the content is restricted</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The restriction message applied, could be empty string</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WP_Post $post The post being restricted</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restricted content HTML</dd>
</dl>
<p>If you wanted to remove a restriction notice completely, you could use this filter to modify the message HTML or delete it. This example snippet shows its use for modifying the restricted content, so you could return the content without the restriction message, or modify the message and return the content as desired.</p>
<h4 id="wc_memberships_product_viewing_restricted_message">wc_memberships_product_viewing_restricted_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The restriction message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $product_id ID of the product being restricted</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $products Array of product IDs that grant access to this product</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restriction message</dd>
</dl>
<p>Filters the product viewing restricted message.</p>
<h4 id="wc_memberships_product_purchasing_restricted_message">wc_memberships_product_purchasing_restricted_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The restriction message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $product_id ID of the product being restricted</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $products Array of product IDs that grant access to this product</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restriction message</dd>
</dl>
<p>Filters the product purchasing restricted message.</p>
<h4 id="wc_memberships_content_restricted_message">wc_memberships_content_restricted_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The restriction message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $post_id ID of the product being restricted</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $products Array of product IDs that grant access to this product</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restriction message</dd>
</dl>
<p>Filters the content restricted message.</p>
<h4 id="wc_memberships_get_content_delayed_message">wc_memberships_get_content_delayed_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.3.1</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message Delayed content message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $post_id Post ID that the message applies to</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $access_time Access time timestamp</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restriction message</dd>
</dl>
<p>Filters the content delayed message.</p>
<p>Example to show a custom delayed message for the “project” post type:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Change the "content delayed" message displayed to members who will have access, but not yet
 * Example: change the delayed content message for the "Projects" post type
 *
 * @param string $message the message html
 * @param string[] $args {
 *      @type string $context whether the message appears in the context of a notice or elsewhere
 *      @type WP_Post $post the post object
 *      @type int $post_id the ID of the restricted post
 *      @type int $access_time the user access timestamp
 *      @type int[] $products the product IDs that grant access
 *      @type string $rule_type the related rule type
 *      @type string|string[] $classes optional message CSS classes
 * }
 * @return string $message the updated message text
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_change_content_delayed_message</span><span class="pun">(</span><span class="pln"> $message</span><span class="pun">,</span><span class="pln"> $args </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="com">// only change the delayed message if a project is being viewed</span><span class="pln">
        </span><span class="com">// {date} will be replaced automatically after this filter with access date</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="str">'project'</span><span class="pln"> </span><span class="pun">===</span><span class="pln"> get_post_type</span><span class="pun">(</span><span class="pln"> $args</span><span class="pun">[</span><span class="str">'post_id'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                $message </span><span class="pun">=</span><span class="pln"> </span><span class="str">'This project is part of your membership, but not yet! You will gain access on {date}'</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="kwd">return</span><span class="pln"> $message</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_content_delayed_message'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_change_content_delayed_message'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">10</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">woocommerce-memberships/frontend/change-content-delayed-access-message.php</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_product_taxonomy_viewing_restricted_message">wc_memberships_product_taxonomy_viewing_restricted_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The restriction message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $taxonomy Product taxonomy</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $term_id Product taxonomy term id</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $products Array of product IDs that grant access to products taxonomy</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restriction message</dd>
</dl>
<p>Filters the product category viewing restricted message. Defaults to, “This product category can only be viewed by members. To view this category, sign up by purchasing {products}, or log in if you are a member.” If no product purchases can grant access to the category, defaults to, “This product category can only be viewed by members.”</p>
<h4 id="wc_memberships_product_term_viewing_delayed_message">wc_memberships_product_term_viewing_delayed_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The delayed access message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $taxonomy Product taxonomy</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $term_id Product taxonomy term id</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated restriction message</dd>
</dl>
<p>Filter the product term viewing delayed access message. Defaults to, “This product category is part of your membership, but not yet! You will gain access on {date}.”</p>
<h4 id="wc_memberships_member_discount_message">wc_memberships_member_discount_message</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $message The discount message</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $product_id ID of the product that has member discounts</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $products Array of product IDs that grant access to this product</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated discount message</dd>
</dl>
<p>Filters the member discount message shown to non-members or non-logged in users.</p>
<p>&nbsp;</p>
<h2 id="section-4">Filters: Member Discounts</h2>
<h4 id="wc_memberships_member_prices_use_discount_format">wc_memberships_member_prices_use_discount_format</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.3.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>bool $use_discount_format Defaults to true</dd>
</dl>
<p>located in: <code>/includes/class-wc-memberships-member-discounts.php</code></p>
<p>Controls whether or not member prices should use discount format when displayed. If returned false, discounted prices will be shown without the original price. Defaults to true.</p>
<h4 id="wc_memberships_member_prices_display_sale_price">wc_memberships_member_prices_display_sale_price</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.3.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>bool $display_sale_price Defaults to false</dd>
</dl>
<p>located in: <code>/includes/class-wc-memberships-member-discounts.php</code></p>
<p>Controls whether or not member prices should display sale prices as well. If returned true, the original price, sale price, and member price will be shown.</p>
<p>Default: <del>$nonmember price</del> $member price<br />
Returned True: <del>$original price</del> <del>$sale price</del> $member price</p>
<p>Defaults to false — only shows sale price [if set] and member price, or original price and member price.</p>
<h4 id="wc_memberships_member_discount_badge">wc_memberships_member_discount_badge</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $badge_html the member discount badge HTML</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WP_Post $post Post object</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Product $product Product object</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – updated badge HTML</dd>
</dl>
<p><em>located in:</em> <code>/templates/loop/member-discount-badge.php</code></p>
<p>Filters the Member Discount badge HTML.</p>
<p>&nbsp;</p>
<h2 id="section-5">Filters: My Memberships</h2>
<h4 id="wc_memberships_my_memberships_title">wc_memberships_my_memberships_title</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.5.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $title My Memberships table title</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – updated title</dd>
</dl>
<p><em>located in:</em> <code>/templates/myaccount/my-memberships.php</code></p>
<p>Filters the title of the My Memberships table. Defaults to “My Memberships”.</p>
<h4 id="wc_memberships_my_memberships_column_names">wc_memberships_my_memberships_column_names</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $my_memberships_columns Associative array of column ids and names</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $user_id ID of logged in user</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of columns</dd>
</dl>
<p><em>located in:</em> <code>/templates/myaccount/my-memberships.php</code></p>
<p>Filters the My Memberships table columns in My Account page. Example: remove “end date” column:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Remove the "End Date" column from the My Memberships table
 *
 * @param array $columns the columns in the "My Memberships" table
 * @return array $columns the updated array of columns
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_remove_end_date_column</span><span class="pun">(</span><span class="pln"> $columns </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        unset</span><span class="pun">(</span><span class="pln"> $columns</span><span class="pun">[</span><span class="str">'membership-end-date'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> $columns</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_my_memberships_column_names'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_remove_end_date_column'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">woocommerce-memberships/frontend/remove-my-memberships-end-date-column.php</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_get_renew_membership_url">wc_memberships_get_renew_membership_url</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $url renewal URL</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – updated URL</dd>
</dl>
<p><em>located in:</em> <code>/includes/class-wc-memberships-user-membership.php</code></p>
<p>Filters the renewal URL for a membership. Helpful if you want to change the renewal URL / button to “upgrade” a membership.</p>
<p>Example: Renew trial plan by purchasing an upgrade.</p>
<h4 id="wc_memberships_get_cancel_membership_url">wc_memberships_get_cancel_membership_url</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $url cancellation URL</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – updated URL</dd>
</dl>
<p><em>located in:</em> <code>/includes/class-wc-memberships-user-membership.php</code></p>
<p>Filters the cancel URL for a membership. Not needed for memberships purchased via subscription, as the button is hidden.</p>
<p>&nbsp;</p>
<h2 id="section-6">Filters: Member Area</h2>
<div class="woo-sc-box info   ">We have an overview of customizing the member area and adding custom sections.</div>
<h4 id="wc_membership_plan_members_area_sections">wc_membership_plan_members_area_sections</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $member_area_sections Associative array with member area id and label of each section</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int|string $membership_plan Optional, the current membership plan, might be empty</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of sections</dd>
</dl>
<p><em>located in:</em> <code>/includes/wc-memberships-membership-plan-functions.php</code></p>
<p>Filters the available choices for the members area sections of a membership plan.</p>
<p>Example: Rename the section links:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Rename the section links for the "Member Area"
 * Can rename any section links using the section ID
 *
 * @param array $sections the array of section link IDs and text
 * @return array $sections the updated array of section links
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_rename_member_area_sections</span><span class="pun">(</span><span class="pln"> $sections </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        $sections</span><span class="pun">[</span><span class="str">'my-membership-content'</span><span class="pun">]</span><span class="pln">   </span><span class="pun">=</span><span class="pln"> __</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Club Articles'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'my-text-domain'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        $sections</span><span class="pun">[</span><span class="str">'my-membership-products'</span><span class="pun">]</span><span class="pln">  </span><span class="pun">=</span><span class="pln"> __</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Club Products'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'my-text-domain'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        $sections</span><span class="pun">[</span><span class="str">'my-membership-discounts'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> __</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Exclusive Discounts'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'my-text-domain'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
        $sections</span><span class="pun">[</span><span class="str">'my-membership-notes'</span><span class="pun">]</span><span class="pln">     </span><span class="pun">=</span><span class="pln"> __</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Notes from MySite'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'my-text-domain'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">

        </span><span class="kwd">return</span><span class="pln"> $sections</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_membership_plan_members_area_sections'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_rename_member_area_sections'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">woocommerce-memberships/frontend/member-area/rename-member-area-section-links.php</div>
</div>
</div>
<p>&nbsp;</p>
<h4 id="wc_memberships_members_area_section_actions">wc_memberships_members_area_{$section}_actions</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $default_actions Associative array of actions</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership User Membership object</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Product|WP_Post|object $object Current object where the action is run (optional)</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of actions</dd>
</dl>
<p><em>located in:</em> <code>/includes/wc-memberships-template-functions.php</code></p>
<p>Filter membership actions on My Account and Members Area pages. The $section is the member area section, e.g., ‘my-membership’, ‘my-membership-content’, etc.</p>
<p>Example: Remove “Cancel” button.</p>
<h3 id="section-7">My Membership Content</h3>
<div class="woo-sc-box normal   ">All hooks for the “My Content” section of the Member Area are located in the template file: <strong>/templates/myaccount/my-membership-content.php</strong></div>
<h4 id="wc_memberships_members_area_my_membership_content_title">wc_memberships_members_area_my_membership_content_title</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $title the section title</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated title</dd>
</dl>
<p>Filters the heading for the “My Content” section.</p>
<h4 id="wc_memberships_members_area_my_membership_content_column_names">wc_memberships_members_area_my_membership_content_column_names</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $columns Associative array of column ids and names</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $user_id ID of logged in user</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of columns</dd>
</dl>
<p>Filters the columns in the “My Content” section. If adding a column, be sure to also fill that column with content using the</p>
<pre>wc_memberships_members_area_my_membership_content_column_{$column_id}</pre>
<p>action. Example to add an “Author” column:</p>
<p>&nbsp;</p>
<div class="gist-it-gist">
<div class="gist-file">
<div class="gist-data">
<pre class="prettyprint"><span class="pun">&lt;?</span><span class="pln">php </span><span class="com">// only copy this line if needed</span>
<span class="com">/**
 * Add an "Author" column to the "My Content" table in the members area
 *
 * @param array $columns the columsn in the "My Content" table
 * @return array $columns the updated array of columns
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_my_content_table_add_column</span><span class="pun">(</span><span class="pln"> $columns </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        $new_columns </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">

        </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> $columns </span><span class="kwd">as</span><span class="pln"> $column_id </span><span class="pun">=&gt;</span><span class="pln"> $column_name </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

                $new_columns</span><span class="pun">[</span><span class="pln"> $column_id </span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> $column_name</span><span class="pun">;</span><span class="pln">

                </span><span class="com">// insert our new "Author" column after the "Title" column</span><span class="pln">
                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="str">'membership-content-title'</span><span class="pln"> </span><span class="pun">===</span><span class="pln"> $column_id </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                        $new_columns</span><span class="pun">[</span><span class="str">'membership-content-author'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> __</span><span class="pun">(</span><span class="pln"> </span><span class="str">'Author'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'your-textdomain'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">

        </span><span class="kwd">return</span><span class="pln"> $new_columns</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_filter</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_members_area_my_membership_content_column_names'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_my_content_table_add_column'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">11</span><span class="pln"> </span><span class="pun">);</span>
<span class="com">/**
 * Fills the "Author" column with the post author
 *
 * @param WP_Post $post the post object used for the row's display
 */</span>
<span class="kwd">function</span><span class="pln"> sv_wc_memberships_my_content_table_add_column_content</span><span class="pun">(</span><span class="pln"> $post </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        $author </span><span class="pun">=</span><span class="pln"> get_user_by</span><span class="pun">(</span><span class="pln"> </span><span class="str">'ID'</span><span class="pun">,</span><span class="pln"> $post</span><span class="pun">-&gt;</span><span class="pln">post_author </span><span class="pun">);</span><span class="pln">
        echo $author</span><span class="pun">-&gt;</span><span class="pln">display_name</span><span class="pun">;</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span><span class="pln"> </span><span class="str">'wc_memberships_members_area_my_membership_content_column_membership-content-author'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'sv_wc_memberships_my_content_table_add_column_content'</span><span class="pln"> </span><span class="pun">);</span></pre>
</div>
<div class="gist-meta">woocommerce-memberships/frontend/member-area/add-author-column-to-my-content.php</div>
</div>
</div>
<p>&nbsp;</p>
<p>You could also remove columns: example to remove “Type” column</p>
<h3 id="section-8">My Membership Products</h3>
<div class="woo-sc-box normal   ">All hooks for the “My Products” section of the Member Area are located in the template file: <strong>/templates/myaccount/my-membership-products.php</strong></div>
<h4 id="wc_memberships_members_area_my_membership_products_title">wc_memberships_members_area_my_membership_products_title</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $title the section title</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated title</dd>
</dl>
<p>Filters the heading for the “My Products” section.</p>
<h4 id="wc_memberships_members_area_my_membership_products_column_names">wc_memberships_members_area_my_membership_products_column_names</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $columns Associative array of column ids and names</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $user_id ID of logged in user</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of columns</dd>
</dl>
<p>Filters the columns in the “My Products” section. If adding a column, be sure to also fill that column with content using the</p>
<pre>wc_memberships_members_area_my_membership_products_column_{$column_id}</pre>
<p>action.</p>
<h3 id="section-9">My Membership Discounts</h3>
<div class="woo-sc-box normal   ">All hooks for the “My Discounts” section of the Member Area are located in the template file: <strong>/templates/myaccount/my-membership-discounts.php</strong></div>
<h4 id="wc_memberships_members_area_my_membership_discounts_title">wc_memberships_members_area_my_membership_discounts_title</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $title the section title</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated title</dd>
</dl>
<p>Filters the heading for the “My Discounts” section. Example to change the heading to “Exclusive Discounts”.</p>
<h4 id="wc_memberships_members_area_my_membership_discounts_column_names">wc_memberships_members_area_my_membership_discounts_column_names</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $columns Associative array of column ids and names</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $user_id ID of logged in user</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of columns</dd>
</dl>
<p>Filters the columns in the “My Discounts” section. If adding a column, be sure to also fill that column with content using the</p>
<pre>wc_memberships_members_area_my_membership_discounts_column_{$column_id}</pre>
<p>action.</p>
<h4 id="wc_memberships_members_area_show_only_active_discounts">wc_memberships_members_area_show_only_active_discounts</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>bool $show_only_active_discounts Default true</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $user_id ID of logged in user</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $product_id ID of discounted product</dd>
</dl>
<p>Filters whether the “My Discounts” area should list all discounts for the membership or only active discounts for the membership. Return false to show all discounts (including inactive discounts).</p>
<h3 id="section-10">Membership Notes</h3>
<div class="woo-sc-box normal   ">All hooks for the “My Discounts” section of the Member Area are located in the template file: <strong>/templates/myaccount/my-membership-notes.php</strong></div>
<h4 id="wc_memberships_members_area_my_membership_notes_title">wc_memberships_members_area_my_membership_notes_title</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $title the section title</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>string – the updated title</dd>
</dl>
<p>Filters the heading for the “Membership Notes” section.</p>
<h4 id="wc_memberships_members_area_my_membership_notes_column_names">wc_memberships_members_area_my_membership_notes_column_names</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>array $columns Associative array of column ids and names</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $user_id ID of logged in user</dd>
<p> </p>
<dt><strong>@return</strong></dt>
<p> </p>
<dd>array – updated array of columns</dd>
</dl>
<p>Filters the columns in the “My Membership Notes” section. If adding a column, be sure to also fill that column with content using the</p>
<pre>wc_memberships_members_area_my_membership_notes_column_{$column_id}</pre>
<p>action.</p>
<p>&nbsp;</p>
<h2 id="section-11">Actions: My Memberships</h2>
<div class="woo-sc-box normal   ">All “My Memberships” actions are located in: <strong>/templates/myaccount/my-memberships.php</strong></div>
<h4 id="wc_memberships_before_my_memberships">wc_memberships_before_my_memberships</h4>
<p>Fired before My Memberships table in My Account page.</p>
<h4 id="wc_memberships_my_memberships_column_column_id">wc_memberships_my_memberships_column_{$column_id}</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.3</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Memberships_User_Membership $user_membership</dd>
</dl>
<p>Fires when the column with $column_id is displayed in the My Memberships table. Used to fill a custom column with content.</p>
<h4 id="wc_memberships_after_my_memberships">wc_memberships_after_my_memberships</h4>
<p>Fired after My Memberships table in My Account page.</p>
<p>&nbsp;</p>
<h2 id="section-12">Actions: Member Area</h2>
<div class="woo-sc-box info   ">We have an overview of customizing the member area and adding custom sections.</div>
<h4 id="wc_memberships_before_members_area">wc_memberships_before_members_area</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $section the section ID</dd>
</dl>
<p>Fires before each section of the member area.</p>
<h4 id="wc_memberships_after_members_area">wc_memberships_after_members_area</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>string $section the section ID</dd>
</dl>
<p>Fires after each section of the member area.</p>
<h4 id="wc_memberships_members_area_my_membership_content_column_column_id">wc_memberships_members_area_my_membership_content_column_{$column_id}</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WP_Post $post the post object for which the row’s data is shown</dd>
</dl>
<p><em>located in:</em> <code>/templates/myaccount/my-membership-content.php</code></p>
<p>Fired for any “My Content” column added with a custom ID. Fills the table cell with content for this column. See this example.</p>
<h4 id="wc_memberships_members_area_my_membership_products_column_column_id">wc_memberships_members_area_my_membership_products_column_{$column_id}</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Product $product the product object for which the row’s data is shown</dd>
</dl>
<p><em>located in:</em> <code>/templates/myaccount/my-membership-products.php</code></p>
<p>Fired for any “My Products” column added with a custom ID. Fills the table cell with content for this column.</p>
<h4 id="wc_memberships_members_area_my_membership_discounts_column_column_id">wc_memberships_members_area_my_membership_discounts_column_{$column_id}</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WC_Product $product the product object for which the row’s data is shown</dd>
</dl>
<p><em>located in:</em> <code>/templates/myaccount/my-membership-discounts.php</code></p>
<p>Fired for any “My Discounts” column added with a custom ID. Fills the table cell with content for this column.</p>
<h4 id="wc_memberships_members_area_my_membership_notes_column_column_id">wc_memberships_members_area_my_membership_notes_column_{$column_id}</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.4.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>object $note the membership note comment object for the row</dd>
</dl>
<p><em>located in:</em> <code>/templates/myaccount/my-membership-notes.php</code></p>
<p>Fired for any “My Membership Notes” column added with a custom ID. Fills the table cell with content for this column.</p>
<p>&nbsp;</p>
<h2 id="section-13">Actions: General</h2>
<h4 id="wc_memberships_activated">wc_memberships_activated</h4>
<p>Runs when Memberships is activated.</p>
<h4 id="wc_memberships_deactivated">wc_memberships_deactivated</h4>
<p>Runs when Memberships is deactivated.</p>
<h4 id="wc_memberships_duplicate_membership_plan">wc_memberships_duplicate_membership_plan</h4>
<dl>
<dt><strong>@since</strong></dt>
<p> </p>
<dd>1.0.0</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>int $new_id New plan ID</dd>
<p> </p>
<dt><strong>@param</strong></dt>
<p> </p>
<dd>WP_Post $post Original plan object</dd>
</dl>
<p><em>located in:</em> <code>/includes/admin/class-wc-memberships-admin-membership-plans.php</code></p>
<p>Fires after a membership plan has been duplicated.</p>
<h2 id="section-14">Table of Contents</h2>
<p>All done here? <a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Return to documentation overview →</a></p>
</div>
<div class="related-docs docs-listing single">
<h2>Relevant Links</h2>
<ul class="recommended-docs">
<li>
<h4><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-2/">Memberships Overview</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/woocommerce-memberships-admin-hook-reference/">Admin Hooks</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/managing-plugins/#Installing_Plugins">Installing Plugins</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/managing-woocommerce-com-subscriptions/">Managing WooCommerce.com subscriptions</a></h4>
</li>
<li>
<h4><a href="https://help.codibu.com/blog/kb/how-to-get-help/">How to Get Help</a></h4>
</li>
</ul>
</div><p>The post <a href="https://help.codibu.com/blog/woocommerce-memberships-frontend-hook-reference/">WooCommerce Memberships Frontend Hook Reference</a> first appeared on <a href="https://help.codibu.com">CODIBU</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://help.codibu.com/blog/woocommerce-memberships-frontend-hook-reference/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
