Table of Contents
This is a non-comprehensive list of functions from the plugin that might be useful.
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.
pms_is_member( $user_id = '', $subscription_plans = array() );
pms_is_member_of_plan( $subscription_plans, $user_id = '' );
This is similar to the function above, it just has the parameter in the reverse order.
Both functions will return true or false.
Example:
if( pms_is_member_of_plan( array( 123 ) ) ) {
echo 'Content for plan 123';
}
pms_is_post_restricted( $post_id );
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 = pms_get_member( $user_id );
This function will return a PMS_Member object which contains information about the given user. The object has the following keys:
$args = array(
'order' => 'DESC',
'orderby' => 'ID',
'number' => 10,
'offset' => '',
'subscription_plan_id' => '',
'member_subscription_status' => '',
'search' => '',
'group_owner' => '',
'payment_gateway' => '',
'start_date_beginning' => '',
'start_date_end' => '',
'expiration_date_beginning' => '',
'expiration_date_end' => '',
);
// array with member objects based on arguments
$members = pms_get_members( $args );
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:
$members = pms_get_members( $args, true );
$payment = pms_get_payment( $payment_id );
This function will return a PMS_Payment object which contains information about a certain payment. The object has the following keys:
$args = array(
'order' => 'DESC',
'orderby' => 'id',
'number' => 10,
'offset' => '',
'status' => '',
'type' => '',
'currency' => '',
'user_id' => '',
'subscription_plan_id' => '',
'profile_id' => '',
'transaction_id' => '',
'date' => '',
'search' => ''
);
$payments = pms_get_payments( $args );
Using this function you can grab a list of payments based on certain arguments.
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:
pms_get_payment_meta( $payment_id = 0, $meta_key = '', $single = false );
For more info see: https://developer.wordpress.org/reference/functions/get_metadata/
pms_add_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $unique = false );
For more info see: https://developer.wordpress.org/reference/functions/add_metadata/
pms_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' );
For more info see: https://developer.wordpress.org/reference/functions/update_metadata/
pms_delete_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $delete_all = false );
For more info see: https://developer.wordpress.org/reference/functions/delete_metadata/
$subscription = pms_get_member_subscription( $subscription_id );
This function will return a PMS_Member_Subscription object which contains information about a certain subscription. The object has the following keys:
$args = array(
'order' => 'DESC',
'orderby' => 'id',
'number' => 1000,
'offset' => '',
'status' => '',
'user_id' => '',
'subscription_plan_id' => '',
'start_date' => '',
'start_date_after' => '',
'start_date_before' => '',
'expiration_date' => '',
'expiration_date_after' => '',
'expiration_date_before' => '',
'billing_next_payment' => '',
'billing_next_payment_after' => '',
'billing_next_payment_before' => '',
'include_abandoned' => false,
);
$subscriptions = pms_get_member_subscriptions( $args );
Using this function you can grab a list of subscriptions based on certain arguments.
$subscription_plan = pms_get_subscription_plan( $subscription_plan_id );
This function will return a PMS_Subscription_Plan object which contains information about a particular subscription plan. The object has the following keys:
$only_active = true;
$include = array();
$exclude = array();
$subscription_plans = pms_get_subscription_plans( $only_active, $include, $exclude );
This function allows you to retrieve a list of all defined subscription plans.
This function let’s you retrieve the URL or ID of specific plugin pages.
$account_page = pms_get_page( 'account', true );
The first parameter can be:
The second parameter determines if the function should return the ID of the page or it’s URL. Setting it to true will return the page URL.
The action links that are shown on the PMS Account page for members can also be generated programatically. For this there are different functions available:
These functions will either return the action URL or false. False is being returned when the action is not available.
Each function can also take a parameter in the form of a $subscription_plan_id. This is useful if you are using the Multiple Subscriptions Per User add-on so you can target specific subscriptions.
The pms_get_upgrade_url()
function will take you to the general Change Subscription page and depending on settings, the user could also Change or Downgrade their subscription plan from that page.
$args = array(
'orderby' => 'ID',
'offset' => '',
'limit' => ''
);
$non_member_users = pms_get_users_non_members( $args );
Retrieve an array of users that are not yet members on your website.
$currency = pms_get_active_currency();
Retrieve the active currency set on the Paid Member Subscriptions -> Settings -> Payments page.
Accept (recurring) payments, create subscription plans and restrict content on your website. Easily setup a WordPress membership site using Paid Member Subscriptions.
Get Paid Member SubscriptionsCombine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.
Get 25% off with the bundle