8

I'm developing a Java client to interact with Moodle. I want to get all the users registered within a Moodle installation.

I found the webservice function called core_user_get_users which returns a list with users.

When I call the service without any parameters I get a repsonse with a invalid parameter exception.

When I add a criteria parameter (criteria[0][key]=id&criteria[0][value]=some_id) it returns a single user with that specific id.

I can't seem to find what criteria to pass to the function to get the entire list with users registered.

1 Answer 1

12

You can use the email criteria. If you have the value %% it will retrieve all registered users.

4
  • 4
    A similar but perhaps more intuitive and useful variant of this approach is to use the deleted field and the value 0, that will return all users that have not been deleted.
    – Bart B
    Commented Aug 4, 2017 at 16:34
  • 1
    @BartB It works but actually it is not intended to as the warning shows when you do so: "item": "deleted", "warningcode": "invalidfieldparameter", "message": "The search key 'deleted' is not supported, look at the web service documentation"
    – wp78de
    Commented Sep 28, 2018 at 20:48
  • 4
    @wp78de everything you do to get all users is a 'hack' because that's not what this API call is really for. The problem is, there is no API call for getting all users 🙁
    – Bart B
    Commented Oct 11, 2018 at 13:51
  • 1
    Actually everything seems to work as a search criteria, even if it does not exist (i.e. idontevenexist instead of deleted) 😅
    – debuglevel
    Commented Apr 6, 2021 at 22:46

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