python-wordpress-xmlrpc icon indicating copy to clipboard operation
python-wordpress-xmlrpc copied to clipboard

Get list of users filtered by role; results limited to 50?

Open mrichman opened this issue 11 years ago • 2 comments

I am trying to get a list of all users where the role is 'subscriber', but the list that comes back seems truncated at 50.

from wordpress_xmlrpc import Client
from wordpress_xmlrpc.methods.users import GetUsers
...
wp = Client(url, username, password)
users = wp.call(GetUsers())
subs = []
for u in users:
    if 'subscriber' in u.roles:
        subs.append((u.email, u.first_name))
return subs

How do I apply the role filter to GetUsers() and how do I get the complete list, not just the first 50 results?

Thanks, Mark

mrichman avatar Sep 17 '13 14:09 mrichman

You need to use the 'offset' parameter to page through the results. See the docs here: http://python-wordpress-xmlrpc.readthedocs.org/en/latest/ref/methods.html#wordpress_xmlrpc.methods.users.GetUsers

maxcutler avatar Sep 19 '13 05:09 maxcutler

I'll try to add examples of using the User methods and paging to the documentation.

maxcutler avatar Feb 12 '14 06:02 maxcutler