Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created May 7, 2014 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strangerstudios/c81fb1c5c4eec67eda97 to your computer and use it in GitHub Desktop.
Save strangerstudios/c81fb1c5c4eec67eda97 to your computer and use it in GitHub Desktop.
Use the WordPress IXR Client to query a remote XMLRPC method.
<?php
function my_init_test()
{
//check for ?test=1 or do nothing
if(empty($_REQUEST['test']))
return;
//user id to test
$remote_user_id = 1;
//load IXR class
require_once ABSPATH . 'wp-includes/class-IXR.php';
//connect
$rpc = new IXR_CLIENT('http://otherwordpresssite.com/xmlrpc.php');
//query
$rpc->query('pmpro.getMembershipLevelForUser', 'adminusername', 'adminpassword', $remote_user_id);
$r = $rpc->getResponse();
//show output and die
wp_die('<pre>' . var_export($r, true) . '</pre>');
}
add_action('init', 'my_init_test');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment