[wp-xmlrpc] login() and error handling (WP 3.1)

Joseph Scott joseph at josephscott.org
Mon Mar 7 16:51:10 UTC 2011


Have you tried using the 'global $wp_xmlrpc_server' instance?

On Sun, Mar 6, 2011 at 1:30 PM, Paul Gibbs <djpaul at gmail.com> wrote:
> 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()?
>



-- 
Joseph Scott
joseph at josephscott.org
http://josephscott.org/


More information about the wp-xmlrpc mailing list