Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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'.

share|improve this question
    
You're trying to do two things. Your working code calls get_previously_saved_permalink() to replace the standard link with one saved elsewhere (post meta perhaps). But now you're trying to hook in to save a different permalink via XMLRPC? –  EAMann May 21 '12 at 21:10
    
The idea is simple: assign a source link (given by XMLRPC protocol) to each post so the permalink filter could read and use it. Now I've get add_permalink to work, I've edited the question removing the text where I said that wordpress was not executing this part. –  Ivan May 22 '12 at 8:49
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

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.