Last active
August 29, 2015 13:56
-
-
Save strangerstudios/9099164 to your computer and use it in GitHub Desktop.
Test code for the XMLRPC methods added to Paid Memberships Pro in PMPro v2.0. Add this to your active theme's functions.php or a custom plugin, then navigate to /?rpctest=1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code is just meant as a sample of how to use the new XMLRPC methods in PMPro. | |
Aftering adding this code, navigate to /?rpctest=1 | |
*/ | |
function xmlrpc_test() | |
{ | |
if(!empty($_REQUEST['rpctest']) && current_user_can("manage_options")) | |
{ | |
//load XMLRPC Client | |
include(ABSPATH . "/wp-includes/class-IXR.php"); | |
$client = new IXR_Client(home_url('xmlrpc.php')); | |
//test values | |
$username = ""; //user login to use | |
$pass = ""; //pass of the admin user | |
$post_id = "1"; //a real post id | |
$user_id = "1"; //if different from the admin | |
//get membership level data for a user | |
$client->query('pmpro.getMembershipLevelForUser',$username,$pass,$user_id); | |
//output | |
echo "<pre>"; | |
print_r($client->message); | |
echo "</pre>"; | |
//does the user have access to post_id? | |
$client->query('pmpro.hasMembershipAccess',$username,$pass,$post_id,$user_id); | |
//output | |
echo "<pre>"; | |
print_r($client->message); | |
echo "</pre>"; | |
exit; | |
} | |
} | |
add_action("init", "xmlrpc_test"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment