TYPE_STANDARD
TYPE_STANDARD
Membership type constant.
Membership model.
A membership defines payment options, access rules and similar details. It is not related to a specific user!
Note that all properties are declared protected but they can be access
directly (e.g. $membership->type
to get the type value).
There are magic methods __get() and __set() that do some validation before
accessing the properties.
$private : boolean
Membership private status.
Private means that the membership will not be displayed on the default registration page and membership list. Users can still stubscribe to the membership via the shortcode [ms-membership-buy] or by otherwise reaching the subscription URL.
sort_by_priority(\MS_Model_Membership $a, \MS_Model_Membership $b) : integer
Sort function used as second param by `uasort()` to sort a membership list by priority.
Memberships with equal priority are sorted alphabeically.
\MS_Model_Membership | $a | |
\MS_Model_Membership | $b |
-1: a < b | 0: a = b | +1: a > b
get_base() : \MS_Model_Membership
Get Membership2 base membership.
Create a new membership if membership does not exist. This is an internal membership which is never displayed anywhere.
The base membership.
get_guest() : \MS_Model_Membership
Get special membership that is assigned to all guests.
Create a new membership if membership does not exist.
The guest membership.
get_user() : \MS_Model_Membership
Get default membership for all logged-in users that did not yet subscribe to any membership.
Create a new membership if membership does not exist.
The guest membership.
update_allowed(integer|string $id) : boolean
Returns the access flag, if a specific membership can subscribe to the current membership.
A special value for $id is 'guest', which is used for all users without a normal membership (is_system() type memberships are not normal)
integer|string | $id | A membership ID or the value 'guest'. |
True if the specified membership can subscribe.
update_replaces(integer|string $id) : boolean
Returns the update-replacement flag, which defines if the OLD membership should be cancelled during subscription.
This is used in cases where the new membership is an upgraded version of the old membership and the user can only have one of both memberships.
integer|string | $id | A membership ID. |
True if the specified membership should be cancelled.
get_rule(string $rule_type) : \MS_Rule
Get protection Rule Model.
Note for network-wide mode: In DB the rules for each site are stored in different objects. When loading a membership we will always load 1 instance of each rule_type, and this is the instance that belongs to the current site! Instances for other sites are not accessible. -> This is why we do not use/need a site_id or similar in this function.
string | $rule_type | The rule model type @see MS_Rule |
The requested rule model.
set_rule( $rule_type, \MS_Rule $rule)
Set protection Rule Model.
Note for network-wide mode: In DB the rules for each site are stored in different objects. When loading a membership we will always load 1 instance of each rule_type, and this is the instance that belongs to the current site! Instances for other sites are not accessible. -> This is why we do not use/need a site_id or similar in this function.
$rule_type | ||
\MS_Rule | $rule | The protection rule to set. |
set_custom_data(string $key, mixed $value)
Either creates or updates the value of a custom data field.
Note: Remember to prefix the $key with a unique string to prevent conflicts with other plugins that also use this function.
string | $key | The field-key. |
mixed | $value | The new value to assign to the field. |
get_after_ms_ends_options() : array
Get after membership expired options.
Memberships can be downgraded to the guest level protection.
{ Returns array of $membership_id => $description. @type int $membership_id The membership Id. @type string $description The expired option description. }
get_members_count(array $args = null) : integer
Get members count of this membership.
This will also count members that have "cancelled" or "expired" subscriptions but not "pending" or "deactivated".
To change this use the filter parameter: $args = array( 'status' => 'all' )
array | $args | The query post args |
The members count.
get_members(array $args = null) : array
Get members list of this membership.
This will also count members that have "cancelled" or "expired" subscriptions but not "pending" or "deactivated".
To change this use the filter parameter: $args = array( 'status' => 'all' )
array | $args | The query post args |
List of members.
has_access_to_current_page(integer $post_id = null) : boolean|null
Verify access to current page.
Verify membership rules hierarchy for content accessed directly. If 'has access' is found, it does have access. Only for active memberships.
integer | $post_id |
True if has access to current page. Default is false. Null means: Rule not relevant for current page.