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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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;
share|improve this answer
    
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 Jul 25 '12 at 7:24
    
i have tried this,,but its returning 50 again.. –  Ravi Jul 25 '12 at 7:37
    
@Ravi I've edited my answer. Hope this helps. –  rofflox Jul 25 '12 at 8:29
    
thank you @rofflox it worked fine,,is it legal to edit those plugins? –  Ravi Jul 25 '12 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. –  rofflox Jul 25 '12 at 11:44
show 5 more comments

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.