WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to overwrite the "metaWeblog.newMediaObject" xmlrpc call so the file is saved remotely. From mw_newMediaObject in class-wp-xmlrpc-server.php, i see that there is a hook:

do_action('xmlrpc_call', 'metaWeblog.newMediaObject');

So I should be able to do something in my plugin like:

add_action ('xmlrpc_call', 'myWewMediaObject');
function myWewMediaObject ($method) {
    if ($method=='metaWeblog.newMediaObject') { 
      //perform some custom action

However, since the do_action call is at the beginning of the mw_newMediaObject function, I am unsure how to stop the execution after my plugin function exists.

Please let me know if I am on the right track and if there is another way to do this.

share|improve this question
up vote 3 down vote accepted

Actually, that hook just lets you tie in to the beginning of executing that function, it doesn't let you override anything.

If you want to replace this function entirely, I recommend two different options:

1. Don't use it

Just define your own XMLRPC method (myNamespace.newMediaObject) and call that instead.

2. Replace it

You can tie in to the xmlrpc_methods filter the same way you would to add a new method and can replace the callback for metaWeblog.newMediaObject:

add_filter( 'xmlrpc_methods', 'myMediaHandler' );
function myMediaHandler( $methods ) {
    $methods[ 'metaWeblog.newMediaObject' ] = 'myMediaObject';

    return $methods;

function myMediaObject( $args ) {
    // ... custom functionality

Just be sure to maintain the same format with the $args array and to call/apply the same actions/filters in your custom method so that you don't run into any surprises.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.