Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

User-related APIs

From MoodleDocs
Revision as of 20:20, 13 April 2013 by Liam Hanks (talk | contribs)

Overview

This is a collection of miscelaneous APIs that can help with doing things with lists of users. Note that, in many cases, the more specific Access API, Groups API, Enrolment API, etc. may be what you need.


User selector

The base class user_selector_base defined in user/selector/lib.php, which you can subclass to make a widget that lets you select users in an AJAX-y way. It is used, for example, on the Add group members page. The best way to learn how to use it is to search the code for other users, and see how they work. The base class also has good PHPdoc comments.


Sorting lists of users

When you fetch a list of users from the database, they should always be sorted consistently, by using the users_order_by_sql function to generate the order-by clause. Again, the best way to see how that works is to search the code for existing uses.


Others

This page is probably incomplete.


See also