How to get all users with core_user_get_users and PHP

How to get all users with core_user_get_users and PHP

by Josip Zmikic -
Number of replies: 1

Hi there,

i have been going round and round witht his problem. I can get specific user if i use their id or email, but i cant get more then one user via api call.

The user i get isnt limited to just admin or loged in user so permisions should be ok.

The web service documentation states that i can use % in my search so my general idea was to send request for email with % criteria and that would return me list of all users that have email.

After that failed i tryed using auth field as a filter but that one never returned anything to me.

Can someone give me a working example for my issue. The curl url i use for this is :

$url.'webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction=core_user_get_users&moodlewsrestformat=json&criteria[0][key]=email&criteria[0][value]=%';

This is just one variation of what i tryed but usuallythe resulti get is either an empty json or just empty result with nothing in it.

Thank you in advance.

Kind regards,

Josip

Average of ratings: Useful (1)
In reply to Josip Zmikic

Re: How to get all users with core_user_get_users and PHP

by Shivanesh Lal -

Hi Josip here's my solution which worked for me 


url/webservice/rest/server.php?wstoken=c1a766e447b1e564f3202c55cfd387d1&wsfunction=core_user_get_users&criteria[0][key]=username&criteria[0][value]=username_value