Store source permalink on XMLRPC calls

In a theme I’m developing, I need to link to the source post when the post has been stored using XMLRPC. That implies that every time WordPress asks for a permalink (using get_permalink()) the theme will return a previously saved link. That’s accomplished by adding a new filter:

add_action('the_permalink', 'filterPermalink');

function filterPermalink($url) {
    $permalink = get_previously_saved_permalink(get_the_ID());
    return $permalink? $permalink : $url;
}

That’s not the problem (by the moment). The problem is, how to make the same with the metaWeblog.newPost function.

Read More

I’ve already tried something like this:

add_filter('xmlrpc_methods','xml_rpc_functions_to_add');

function xml_rpc_functions_to_add($args) {
    $args['metaWeblog.newPost'] = 'add_permalink';
    return $args;
}

function add_permalink($args) {
    // Do it
}

What I need is to know how to call the previous ‘metaWeblog.newPost’ from ‘add_permalink’.

Related posts

Leave a Reply

1 comment

  1. From look at source metaWeblog.newPost seems to be processed in wp_xmlrpc_server->mw_newPost() method.

    At the end of this method there is following hook call:

    do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args );
    

    which seems to be very fitting to process and save any additional information for post that have just been created by its ID provided.