-1

In my iphone app i am trying to list out all the users using the wp.getUsers XML-RPC method, but its not returning all the users, in that blog i have around 180 members , but it has returned only 50 users in the list,,how can i get all the users ??

i am passing these following 3 parameters blog_id, username and password ,,should i pass any other parameter to get all the users in the list?? plas help me out thanx in advance

1 Answer 1

1

I'm unable to find a XML-RPC method called wp.getUsers in wp-includes/class-wp-xmlrpc-server.php. Could it be, that you're using an additional plugin that extends the basic behavior of WordPress?

A simple google search for 'wp.getUsers' points me to the the github repo of Max Cutler and the class wp-xmlrpc-modernization. There you have a method wp.getUsers which accepts a filter array as 4th parameter.

The optional $filter parameter modifies the query used to retrieve users. * Accepted keys are 'number' (default: 50), 'offset' (default: 0), and 'role'.

EDIT

wp.getUsers is using get_users / WP_Users_Query in the background. Therefore you have to set the number parameter to false if you don't want a LIMIT clause in the SQL statement.

Here is a snippet from the WP_Users_Query class which builts the SQL statement based on the parameters.

    // limit
    if ( $qv['number'] ) {
        if ( $qv['offset'] )
            $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
        else
            $this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']);
    }

Unfortunately the wp-xmlrpc-modernization plugin filters the parameter number with the function absint which sanitize a boolean into an integer. You have to edit the plugin and remove/change this filter on line 808.

$query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50;
9
  • thanx for ur reply @rofflox , ya i had installed wp-xmlrpc-modernization plugin , what should i pass in filter to get all users suppose i dont know how many users are there on the blog?
    – Ravi
    Commented Jul 25, 2012 at 7:24
  • i have tried this,,but its returning 50 again..
    – Ravi
    Commented Jul 25, 2012 at 7:37
  • @Ravi I've edited my answer. Hope this helps.
    – Roman
    Commented Jul 25, 2012 at 8:29
  • thank you @rofflox it worked fine,,is it legal to edit those plugins?
    – Ravi
    Commented Jul 25, 2012 at 9:05
  • @Ravi Of course it's legal, the plugin is released under GPLv2+. The only reason against altering existing code: It is not update safe. Everytime you update the plugin, you also have to alter the code again. You could contact the developer and ask for a fix in the plugin itself.
    – Roman
    Commented Jul 25, 2012 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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