Since version 1.7.8 of PMPro, we have offered two API methods accessible through the WordPress XMLRPC API. This article will describe how to use them and show some examples.


Arguments: username, password, user_id
Returns: False for non-members, or an array containing the membership level values for members
Notes: The username and password args should be for an admin user or user given the “pmpro_xmlrpc” capability.


Arguments: username, password, post_id, user_id, return_membership_levels
Returns: Checks if user user_id has access to post post_id and returns true or false. If return_membership_levels is set to true then returns an array whose first value is true or false based on access and the second value is an array of membership levels that have access to that post.
Notes: The username and password args should be for an admin user or user given the “pmpro_xmlrpc” capability.

These methods are defined in the includes/xmlrpc.php file of the plugin.

Sample Using the PMPro XMLRPC Methods

This example can be loaded into the codebase of a separate WordPress site and will use the XMLRPC client bundled with WordPress to access the membership level data for a user on a different system. This is a bare bones example. A real life example might use the wp.getUser method built into WordPress to get the user ID of a user based on a given email address and then use that user ID in the call to pmpro.getMembershipLevelForUser.

You can write a similar call for communicating between your WordPress site and a .NET environment, an IOS or Android App or more. Just find the documentation for making XMLRPC calls on your platform.

How to Build a Simple RESTful API to get PMPro Data

An alternative to using the XMLRPC API is to build simple RESTful scripts to return specific data when specific parameters are passed into a WordPress URL. This method is less secure since there is no user authentication, but it also doesn’t require you to save a username and password in plaintext in a different system that might be used to access parts of your WordPress system you didn’t intend to make public. In general, more measures should be made to make these APIs secure when using them on live sites.

Here is an example that can be added to a client WordPress site’s functions.php or a custom plugin so that when you visit /? on the site a JSON encoded arary of membership level data is returned for that user specified. This is very similar to the pmpro.getMembershipLevelForUser XMLRPC example above.

For information on how to create custom plugins for WordPress see our PMPro Customizations plugin.

For more information on how to build your own XMLPRC methods in WordPress see:

For more information on the XML-RPC WordPress API, see:

This entry was posted by Jason Coleman in Recipes and tagged . Bookmark the permalink. Last updated: March 16, 2015. Titled Interacting with Paid Memberships Pro Through APIs

Comments (8)

Hi i want to send user data to external system when user register successfully. Can you please tell me on which page data is submit when user fill checkout form and press pay now button?

One of the benefits of an external service I offer is membership to PMP WordPress. I want my external service to call the api and cancel a membership when my external service is not renewed. Can you steer me in the right direction?

How are you giving them membership when they sign up for the external service?

We don’t have an endpoint in the WP REST API to cancel/change membership yet, but we could build one out for you. Or if you go the “custom API” route, you could setup your WP site to listen for something like /wp-admin/admin-ajax.php?action=cancel_member&user_id={user_id}&secretkey={something you keep secret}. Use wp_ajax_nopriv_cancel_member hook, check for the user id, check the secret key, then call pmpro_changeMembershipLevel(0, $user_id)

We can help in the member forums if you need further assistance.

I’d like to create a user from a mobile app client (say someone registers using the mobile app, I’d like to create that user in paid membership pro), which API would I be using? The ones stated here only fetch information about the already existing users.

I think Bruce was looking for a way to create a new membership. I’m also interested in this topic. Say we want to take the payment on another platform and create a new membership programmatically? How would one do that>

I was working a bit with this code and thought I might post my result in case anyone else needed something similar.

In this snippet I send the userid insted of the email to the api.

$user = get_user_by(“login”, str_replace(” “, “+”, ($_REQUEST[‘verify’])));
wp_die(“User not found.”);
$user_id = $user->ID;
$membership_level = pmpro_getMembershipLevelForUser($user_id);

I used this in angularjs to call the subscriptionID for users.

Leave a Reply

Your email address will not be published. Required fields are marked *