Contents
This is a non-comprehensive list of functions from the plugin that might be useful.
Content Restriction
Check if user is member
These functions can be useful if you want to add restricted content directly in your PHP templates. It lets you check if a user is subscribed to one or more subscription plans.Array
- $user_id -> the user ID we want to check, defaults to currently logged in user if empty
- $subscription_plans -> array of subscription plan ids the user should be subscribed to
Array
This is similar to the function above, it just has the parameter in the reverse order.
Both functions will return true or false.
Example:Array
Check if post is restricted for current user
Array
This function lets you check if a particular post is restricted for the current user or not. It will return true or false.
As an example, this function could be useful on an archive page if you want to display a custom icon for posts that the current user can’t access.
Member information
Retrieve information about a member
Array
This function will return a PMS_Member object which contains information about the given user. The object has the following keys:
- user_id
- username
- subscriptions – this key contains an array of subscriptions; each subscription is an array with the following keys
- id – id of the membership
- subscription_plan_id
- start_date
- expiration_date
- status
- payment_profile_id
Get a list of members
Using this function you can grab a list of member objects based on certain arguments.
The function also takes a second parameter $count that can be set to `true` to make the function return the number of users instead of the member objects:Array
Payments
Retrieve information about a payment
Array
This function will return a PMS_Payment object which contains information about a certain payment. The object has the following keys:
- id
- user_id
- subscription_id – this is the Subscription Plan ID, not the ID of the Membership
- status
- date
- amount
- type
- payment_gateway
- transaction_id
- profile_id
- ip_address
- discount_code
Get a list of payments
Using this function you can grab a list of payments based on certain arguments.
Payments meta
Paid Member Subscriptions is using a meta system similar to WordPress Posts or Users for it’s custom payments. You can interact with it through the following functions:Array
- $payment_id – id of the payment
- $meta_key – key we want to retrieve
- $single – if the function should return a single value or multiple
For more info see: https://developer.wordpress.org/reference/functions/get_metadata/Array
- $payment_id – id of the payment
- $meta_key – key we want to add
- $meta_value – value we want to add
- $single – whether the specified metadata key should be unique for the object. If true, and the object already has a value for the specified metadata key, no change will be made
For more info see: https://developer.wordpress.org/reference/functions/add_metadata/Array
- $payment_id – id of the payment
- $meta_key – key we want to update
- $meta_value – value we want to set
- $prev_value – only update if existing value matches this field
For more info see: https://developer.wordpress.org/reference/functions/update_metadata/Array
- $payment_id – id of the payment
- $meta_key – key we want to delete
- $meta_value – value we want to delete
- $delete_all – If true, delete matching metadata entries for all payments, ignoring the specified payment_id. Otherwise, only delete matching metadata entries for the specified payment_id
For more info see: https://developer.wordpress.org/reference/functions/delete_metadata/
Paid Member Subscriptions Pro
Accept (recurring) payments, create subscription plans and restrict content on your website. Easily setup a WordPress membership site using Paid Member Subscriptions.
Unlock PRO Features