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.
This github repo has
bdn.getPosts
extended XML-RPC function to get category.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.
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
andlist_terms_exclusions
filters are called via the blogger.getRecentPosts XML-RPC method. Inside this function, it callswp_get_recent_posts
which usesget_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.Inside your callback, hook into the
pre_get_posts
andlist_terms_exclusions
filters.