[wp-hackers] Importing custom format into WordPress
Owen Winkler
ringmaster at midnightcircus.com
Fri Dec 30 16:43:07 GMT 2005
Aaron Brazell wrote:
> I'd be interested to carry this conversation on to get as much input as
> possible before trying to tackle such a plugin. XML-RPC isn't really my
> thing.
New XMLRPC hooks are really easy to implement in WordPress.
Just add a sink to 'xmlrpc_methods'. The incoming parameter is an array
of supported methods. Add a new array element using the method name as
the key and the function name as the value:
add_filter('xmlrpc_methods', 'attach_new_xmlrpc');
function attach_new_xmlrpc($methods)
{
$methods['wordpress.getusers'] = 'wprpc_getusers';
return $methods;
}
Then implement the function you added to dispatch the RPC:
function wprpc_getusers($args)
{
$user_login = $args[0];
$user_pass = $args[1];
// Verify user
if (!user_pass_ok($user_login, $user_pass))
return new IXR_Error(403, 'Bad login/pass combination.');
// Good login, return the requested info...
return a_function_that_returns_user_data();
}
Consuming XMLRPC isn't hard either. Feel lucky about the "Incutio
XMLRPC" library used in WordPress for more info.
Owen
More information about the wp-hackers
mailing list