A Cozmoslabs Product

Useful Functions

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.

1
pms_is_member( $user_id = '', $subscription_plans = array() )
  1. $user_id -> the user ID we want to check, defaults to currently logged in user if empty
  2. $subscription_plans -> array of subscription plan ids the user should be subscribed to
1
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:

1
2
3
if( pms_is_member_of_plan( array( 123 ) ) ) {
    echo 'Content for plan 123';
}

Check if post is restricted for current user

1
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 information

Retrieve information about a member

1
$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:

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:

1
$members = pms_get_members( $args, true );

Payments

Retrieve information about a payment

1
$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:

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:

1
pms_get_payment_meta( $payment_id = 0, $meta_key = '', $single = false )

For more info see: https://developer.wordpress.org/reference/functions/get_metadata/

1
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/

1
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/

1
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/

The Ultimate Membership Bundle

Combine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.

Get 25% off with the bundle

Help & Support

We’re here to help you every step of the way.

Open a Support Ticket