python-wordpress-xmlrpc
python-wordpress-xmlrpc copied to clipboard
Get list of users filtered by role; results limited to 50?
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
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
I'll try to add examples of using the User methods and paging to the documentation.