[wp-xmlrpc] login() and error handling (WP 3.1)
Paul Gibbs
djpaul at gmail.com
Sun Mar 6 20:30:16 UTC 2011
Hi
I am working on adding XML-RPC support to a plugin. I have a query around wp_xmlrpc_server::login and error handling, and would appreciate information on the proper way to do this.
I am using the 'xmlrpc_methods' filter to register my custom XML-RPC function. As part of my function, I need to check if the user is logged in. This is pretty straightforward but when I intentionally supply invalid credentials, wp_xmlrpc_server::login sets $this->error. As I've invoked login() statically, $this doesn't exist and PHP throws a PHP fatal error ("Using $this when not in object context").
Should I either:
a) duplicate login() into a custom function in my plugin and use that?
b) should WordPress' login() function be modified to return the IXR_Error object rather than set $this->error? (obviously would need to update the rest of WP's XML-RPC functions to handle this change)?
c) or just create my own wp_xmlrpc_server object within my function and use that object's login()?
Thanks
Regards
Paul Gibbs
More information about the wp-xmlrpc
mailing list