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.

Is it possible to filter the posts or categories that XML-RPC users see in their mobile application?

I have a plugin that hooks into pre_get_posts and list_terms_exclusions to do what I need it to do. I've had requests to allow the same functionality on their mobile devices.

share|improve this question
    
Funny. I was just watching this talk on wp.tv wordpress.tv/2010/01/23/daniel-jalkut-apis-boston10 but it stopped after some minutes. Maybe the answer is hidden in there... –  kaiser Mar 18 '11 at 0:17

3 Answers 3

This github repo has bdn.getPosts extended XML-RPC function to get category.

Get 10 most recently modified posts in the sports category ($category can be either a slug or an ID)

   `array( 1, $username, $password, 'post', 'sports', 10, array( 'orderby' => 'modified' ) );`
share|improve this answer

I have not actually experimented with it myself but when I cracked open the xmlrpc.php file I noticed several do actions for xmlrpc_call.

I suspect that you could add actions based on user type to the xmlrpc call.
E.g. blogger_getPost() can be hooked with xmlrpc_call when xmlrpc_call == blogger.getPost.

share|improve this answer
up vote 0 down vote accepted

Okay, so I discovered the answer to my question.

It is possible to filter the posts and categories that users see in their XML-RPC application. The pre_get_posts and list_terms_exclusions filters are called via the blogger.getRecentPosts XML-RPC method. Inside this function, it calls wp_get_recent_posts which uses get_posts. In other words, there's really nothing special you have to do if you are hooking into the above filters.

My problem was that for my plugin, I was only filtering while in the admin: if ( is_admin()

SOLUTION

In order to make sure it only fires when requested through an XML-RPC application, all you have to do is check for the XMLRPC_REQUEST constant and hook into the xmlrpc_call action.

if ( defined ( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
    add_action( 'xmlrpc_call', array( &$this, 'posts' ) );
}

Inside your callback, hook into the pre_get_posts and list_terms_exclusions filters.

share|improve this answer

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.