Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Files | Namespaces | Classes | Functions | Variables
core_user

Files

file  anycourses.php
 This is filter is used to see which students are enroled on any courses.
 
file  behat_user.php
 User steps definition.
 
file  calendar_form.php
 Form to edit a users preferred language.
 
file  category.php
 Defines a category in my profile page navigation.
 
file  checkbox.php
 Generic checkbox filter.
 
file  cohort.php
 Cohort filter.
 
file  course_form.php
 Form to edit a users course preferences.
 
file  courserole.php
 Course role filter.
 
file  date.php
 Date filter.
 
file  defaulthomepage_form.php
 Form to allow user to set their default home page.
 
file  definelib.php
 This file contains the profile_define_base class.
 
file  edit_form.php
 Form to edit a users profile.
 
file  editadvanced_form.php
 Form for editing a users profile.
 
file  editlib.php
 This file contains function used when editing a users profile and preferences.
 
file  editor_form.php
 Form to edit a users editor preferences.
 
file  files_form.php
 minimalistic edit form
 
file  forum_form.php
 Form to edit a users forum preferences.
 
file  globalrole.php
 Global role filter.
 
file  index_category_form.php
 This file contains the profile field category form.
 
file  index_field_form.php
 This file contains the Field Form used for profile fields.
 
file  language_form.php
 Form to edit a users preferred language.
 
file  lib.php
 Code for ajax user selectors.
 
file  lib.php
 Profile field API library file.
 
file  lib.php
 This file contains the User Filter API.
 
file  manager.php
 Defines Manager class for my profile navigation tree.
 
file  node.php
 Defines a node in my profile page navigation.
 
file  participants_table.php
 Contains the class used for the displaying the participants table.
 
file  profilefield.php
 Profile field filter.
 
file  renderer.php
 myprofile renderer.
 
file  select.php
 Value select filter.
 
file  simpleselect.php
 Simple value select filter.
 
file  status_field.php
 Class containing the data necessary for rendering the status field in the course participants page.
 
file  text.php
 Text field filter.
 
file  tree.php
 Defines profile page navigation tree.
 
file  unified_filter.php
 Class containing the filter options data for rendering the unified filter autocomplete element for the course participants page.
 
file  user.php
 Search area for Users for whom I have authority to view profile.
 
file  user_filter_forms.php
 This file contains forms used to filter user.
 
file  user_profile_set.php
 User profile set indicator.
 
file  user_roles_editable.php
 Contains class core_user\output\user_roles_editable.
 
file  user_summary_exporter.php
 Class for exporting a user summary from an stdClass.
 
file  user_track_forums.php
 User tracks forums indicator.
 
file  yesno.php
 Yes/No (boolean) filter.
 

Namespaces

 core_user
  
 
 core_user\analytics\indicator
  
 
 core_user\external
  
 
 core_user\form
  
 
 core_user\output
  
 
 core_user\output\myprofile
  
 
 core_user\privacy
  
 
 core_user\search
  
 

Classes

class  behat_user
 
class  category_form
 Class category_form. More...
 
class  core_user\analytics\indicator\user_profile_set
 User profile set indicator. More...
 
class  core_user\analytics\indicator\user_track_forums
 User tracks forums indicator. More...
 
class  core_user\course_form
 Class user_course_form. More...
 
class  core_competency\external\user_summary_exporter
 Class for exporting a user summary from an stdClass. More...
 
class  core_user\form\calendar_form
 Class user_edit_calendar_form. More...
 
class  core_user\form\defaulthomepage_form
 Form class. More...
 
class  core_user\output\myprofile\category
 Defines a category in my profile page navigation. More...
 
class  core_user\output\myprofile\manager
 Defines MAnager class for myprofile navigation tree. More...
 
class  core_user\output\myprofile\node
 Defines a node in my profile page navigation. More...
 
class  core_user\output\myprofile\renderer
 Report log renderer's for printing reports. More...
 
class  core_user\output\myprofile\tree
 Defines my profile page navigation tree. More...
 
class  core_user\output\status_field
 Class containing the data for the status field. More...
 
class  core_user\output\unified_filter
 Class containing the filter options data for rendering the unified filter autocomplete element for the course participants page. More...
 
class  core_user\output\user_roles_editable
 Class to display list of user roles. More...
 
class  core_user\participants_table
 Class for the displaying the participants table. More...
 
class  core_user\privacy\provider
 Privacy class for requesting user data. More...
 
class  core_user\search\user
 Search area for Users for whom I have access to view profile. More...
 
class  core_user_external
 
class  core_user_renderer
 Provides user rendering functionality such as printing private files tree and displaying a search utility. More...
 
class  field_form
 Class field_form. More...
 
class  group_members_selector
 User selector subclass for the list of users who are in a certain group. More...
 
class  group_non_members_selector
 User selector subclass for the list of users who are not in a certain group. More...
 
class  groups_user_selector_base
 Base class to avoid duplicating code. More...
 
class  profile_define_base
 Class profile_define_base. More...
 
class  profile_field_base
 Base class for the customisable profile fields. More...
 
class  user_active_filter_form
 Class user_active_filter_form. More...
 
class  user_add_filter_form
 Class user_add_filter_form. More...
 
class  user_edit_editor_form
 Class user_edit_editor_form. More...
 
class  user_edit_form
 Class user_edit_form. More...
 
class  user_edit_forum_form
 Class user_edit_forum_form. More...
 
class  user_edit_language_form
 Class user_edit_form. More...
 
class  user_editadvanced_form
 Class user_editadvanced_form. More...
 
class  user_files_form
 Class user_files_form. More...
 
class  user_filter_anycourses
 User filter to distinguish users with no or any enroled courses. More...
 
class  user_filter_checkbox
 Generic filter based for checkbox and can be used for disabling items. More...
 
class  user_filter_cohort
 Generic filter for cohort membership. More...
 
class  user_filter_courserole
 User filter based on roles in a course identified by its shortname. More...
 
class  user_filter_date
 Generic filter based on a date. More...
 
class  user_filter_globalrole
 User filter based on global roles. More...
 
class  user_filter_profilefield
 User filter based on values of custom profile fields. More...
 
class  user_filter_select
 Generic filter based on a list of values. More...
 
class  user_filter_simpleselect
 Generic filter based on a list of values. More...
 
class  user_filter_text
 Generic filter for text fields. More...
 
class  user_filter_type
 The base user filter class. More...
 
class  user_filter_yesno
 Generic yes/no filter with radio buttons for integer fields. More...
 
class  user_filtering
 User filtering wrapper class. More...
 
class  user_selector_base
 Base class for user selectors. More...
 

Functions

 can_view_user_details_cap ($user, $course=null)
 Check if $USER have the necessary capabilities to obtain user details. More...
 
 cancel_email_update ($userid)
 Cancels the requirement for a user to update their email address. More...
 
 core_user_inplace_editable ($itemtype, $itemid, $newvalue)
 Callback for inplace editable API. More...
 
 profile_definition ($mform, $userid=0)
 Print out the customisable categories and fields for a users profile. More...
 
 profile_definition_after_data ($mform, $userid)
 Adds profile fields to user edit forms. More...
 
 profile_delete_category ($id)
 Delete a profile category. More...
 
 profile_delete_field ($id)
 Deletes a profile field. More...
 
 profile_display_fields ($userid)
 Display profile fields. More...
 
 profile_edit_category ($id, $redirect)
 Edit a category. More...
 
 profile_edit_field ($id, $datatype, $redirect)
 Edit a profile field. More...
 
 profile_get_custom_fields ($onlyinuserobject=false)
 Obtains a list of all available custom profile fields, indexed by id. More...
 
 profile_get_signup_fields ()
 Retrieves a list of profile fields that must be displayed in the sign-up form. More...
 
 profile_get_user_fields_with_data ($userid)
 Returns an array of all custom field records with any defined data (or empty data), for the specified user id. More...
 
 profile_get_user_fields_with_data_by_category ($userid)
 Returns an array of all custom field records with any defined data (or empty data), for the specified user id, by category. More...
 
 profile_has_required_custom_fields_set ($userid)
 Does the user have all required custom fields set? More...
 
 profile_list_categories ()
 Retrieve a list of categories and ids suitable for use in a form. More...
 
 profile_list_datatypes ()
 Retrieve a list of all the available data types. More...
 
 profile_load_custom_fields ($user)
 Load custom profile fields into user object. More...
 
 profile_load_data ($user)
 Loads user profile field data into the user object. More...
 
 profile_move_category ($id, $move)
 Change the sort order of a category. More...
 
 profile_move_field ($id, $move)
 Change the sort order of a field. More...
 
 profile_reorder_categories ()
 Reorder the profile categoriess starting at the category at the given startorder.
 
 profile_reorder_fields ()
 Reorder the profile fields within a given category starting at the field at the given startorder.
 
 profile_save_custom_fields ($userid, $profilefields)
 Save custom profile fields for a user. More...
 
 profile_save_data ($usernew)
 Saves profile data for a user. More...
 
 profile_signup_fields ($mform)
 Adds code snippet to a moodle form object for custom profile fields that should appear on the signup page. More...
 
 profile_user_record ($userid, $onlyinuserobject=true)
 Returns an object with the custom profile fields set for the given user. More...
 
 profile_validation ($usernew, $files)
 Validates profile data. More...
 
 profile_view ($user, $context, $course=null)
 Trigger a user profile viewed event. More...
 
 user_add_password_history ($userid, $password)
 Add password to the list of used hashes for this user. More...
 
 user_can_view_profile ($user, $course=null, $usercontext=null)
 Check if the current user has permission to view details of the supplied user. More...
 
 user_convert_text_to_menu_items ($text, $page)
 Converts a string into a flat array of menu items, where each menu items is a stdClass with fields type, url, title, pix, and imgsrc. More...
 
 user_count_login_failures ($user, $reset=true)
 Count the number of failed login attempts for the given user, since last successful login. More...
 
 user_create_user ($user, $updatepassword=true, $triggerevent=true)
 Creates a user. More...
 
 user_delete_user ($user)
 Marks user deleted in internal user database and notifies the auth plugin. More...
 
 user_edit_map_field_purpose ($userid, $fieldname)
 Map an internal field name to a valid purpose from: "https://www.w3.org/TR/WCAG21/#input-purposes". More...
 
 user_get_course_lastaccess_sql ($accesssince=null, $tableprefix='ul')
 Returns SQL that can be used to limit a query to a period where the user last accessed a course. More...
 
 user_get_default_fields ()
 Returns the list of default 'displayable' fields. More...
 
 user_get_participants ($courseid, $groupid=0, $accesssince, $roleid, $enrolid=0, $statusid, $search, $additionalwhere='', $additionalparams=array(), $sort='', $limitfrom=0, $limitnum=0)
 Returns the participants for a given course. More...
 
 user_get_participants_sql ($courseid, $groupid=0, $accesssince=0, $roleid=0, $enrolid=0, $statusid=-1, $search='', $additionalwhere='', $additionalparams=array())
 Returns the SQL used by the participants table. More...
 
 user_get_tagged_users ($tag, $exclusivemode=false, $fromctx=0, $ctx=0, $rec=1, $page=0)
 Returns users tagged with a specified tag. More...
 
 user_get_total_participants ($courseid, $groupid=0, $accesssince=0, $roleid=0, $enrolid=0, $statusid=-1, $search='', $additionalwhere='', $additionalparams=array())
 Returns the total number of participants for a given course. More...
 
 user_get_user_details ($user, $course=null, array $userfields=array())
 Give user record from mdl_user, build an array contains all user details. More...
 
 user_get_user_details_courses ($user)
 Tries to obtain user details, either recurring directly to the user's system profile or through one of the user's course enrollments (course profile). More...
 
 user_get_user_lastaccess_sql ($accesssince=null, $tableprefix='u')
 Returns SQL that can be used to limit a query to a period where the user last accessed the system. More...
 
 user_get_user_navigation_info ($user, $page, $options=array())
 Get a list of essential user navigation items. More...
 
 user_get_users_by_id ($userids)
 Get users by id. More...
 
 user_is_previously_used_password ($userid, $password)
 Was this password used before on change or reset password page? More...
 
 user_list_view ($course, $context)
 Trigger user_list_viewed event. More...
 
 user_mygrades_url ($userid=null, $courseid=SITEID)
 Returns the url to use for the "Grades" link in the user navigation. More...
 
 user_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types. More...
 
 user_remove_user_device ($uuid, $appid="")
 Remove a user device from the Moodle database (for PUSH notifications usually). More...
 
 user_update_user ($user, $updatepassword=true, $triggerevent=true)
 Update a user with a user object (will compare against the ID) More...
 
 useredit_get_disabled_name_fields ($enabledadditionalusernames=null)
 Gets user name fields not enabled from the setting fullnamedisplay. More...
 
 useredit_get_enabled_name_fields ()
 Gets enabled (from fullnameformate setting) user name fields in appropriate order. More...
 
 useredit_get_required_name_fields ()
 Return required user name fields for forms. More...
 
 useredit_load_preferences (&$user, $reload=true)
 Loads the given users preferences into the given user object. More...
 
 useredit_setup_preference_page ($userid, $courseid)
 Performs the common access checks and page setup for all user preference pages. More...
 
 useredit_shared_definition (&$mform, $editoroptions, $filemanageroptions, $user)
 Powerful function that is used by edit and editadvanced to add common form elements/rules/etc. More...
 
 useredit_update_bounces ($user, $usernew)
 Updates the user email bounce + send counts when the user is edited. More...
 
 useredit_update_interests ($user, $interests)
 Updates a users interests. More...
 
 useredit_update_picture ()
 
 useredit_update_trackforums ($user, $usernew)
 Updates the forums a user is tracking when the user is edited. More...
 
 useredit_update_user_preference ($usernew)
 Updates the user preferences for the given user. More...
 

Variables

global core_user::$CFG
 
 core_user::if (!defined( 'MOODLE_INTERNAL'))
 
 core_user\form::if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
const PROFILE_VISIBLE_ALL '2'
 Visible to anyone who can view the user. More...
 
const PROFILE_VISIBLE_NONE '0'
 Only visible to users with the moodle/user:viewalldetails capability. More...
 
const PROFILE_VISIBLE_PRIVATE '1'
 Visible to the profile owner or anyone with the moodle/user:viewalldetails capability. More...
 
const USER_FILTER_ENROLMENT 1
 
const USER_FILTER_GROUP 2
 
const USER_FILTER_LAST_ACCESS 3
 
const USER_FILTER_ROLE 4
 
const USER_FILTER_STATUS 5
 
const USER_FILTER_STRING 6
 
const USER_SELECTOR_DEFAULT_ROWS 20
 The default size of a user selector.
 

Detailed Description

Function Documentation

◆ can_view_user_details_cap()

can_view_user_details_cap (   $user,
  $course = null 
)

Check if $USER have the necessary capabilities to obtain user details.

Parameters
stdClass$user
stdClass$courseif null then only consider system profile otherwise also consider the course's profile.
Return values
booltrue if $USER can view user details.

◆ cancel_email_update()

cancel_email_update (   $userid)

Cancels the requirement for a user to update their email address.

Parameters
int$userid

◆ core_user_inplace_editable()

core_user_inplace_editable (   $itemtype,
  $itemid,
  $newvalue 
)

Callback for inplace editable API.

Parameters
string$itemtype- Only user_roles is supported.
string$itemid- Courseid and userid separated by a :
string$newvalue- json encoded list of roleids.
Return values
core

◆ profile_definition()

profile_definition (   $mform,
  $userid = 0 
)

Print out the customisable categories and fields for a users profile.

Parameters
moodleform$mforminstance of the moodleform class
int$useridid of user whose profile is being edited.

◆ profile_definition_after_data()

profile_definition_after_data (   $mform,
  $userid 
)

Adds profile fields to user edit forms.

Parameters
moodleform$mform
int$userid

◆ profile_delete_category()

profile_delete_category (   $id)

Delete a profile category.

Parameters
int$idof the category to be deleted
Return values
boolsuccess of operation

◆ profile_delete_field()

profile_delete_field (   $id)

Deletes a profile field.

Parameters
int$id

◆ profile_display_fields()

profile_display_fields (   $userid)

Display profile fields.

Parameters
int$userid

◆ profile_edit_category()

profile_edit_category (   $id,
  $redirect 
)

Edit a category.

Parameters
int$id
string$redirect

◆ profile_edit_field()

profile_edit_field (   $id,
  $datatype,
  $redirect 
)

Edit a profile field.

Parameters
int$id
string$datatype
string$redirect

◆ profile_get_custom_fields()

profile_get_custom_fields (   $onlyinuserobject = false)

Obtains a list of all available custom profile fields, indexed by id.

Some profile fields are not included in the user object data (see profile_user_record function above). Optionally, you can obtain only those fields that are included in the user object.

To be clear, this function returns the available fields, and does not return the field values for a particular user.

Parameters
bool$onlyinuserobjectTrue if you only want the ones in $USER
Return values
arrayArray of field objects from database (indexed by id)
Since
Moodle 2.7.1

◆ profile_get_signup_fields()

profile_get_signup_fields ( )

Retrieves a list of profile fields that must be displayed in the sign-up form.

Return values
arraylist of profile fields info
Since
Moodle 3.2

◆ profile_get_user_fields_with_data()

profile_get_user_fields_with_data (   $userid)

Returns an array of all custom field records with any defined data (or empty data), for the specified user id.

Parameters
int$userid
Return values
profile_field_base[]

◆ profile_get_user_fields_with_data_by_category()

profile_get_user_fields_with_data_by_category (   $userid)

Returns an array of all custom field records with any defined data (or empty data), for the specified user id, by category.

Parameters
int$userid
Return values
profile_field_base[][]

◆ profile_has_required_custom_fields_set()

profile_has_required_custom_fields_set (   $userid)

Does the user have all required custom fields set?

Internal, to be exclusively used by user_not_fully_set_up() only.

Note that if users have no way to fill a required field via editing their profiles (e.g. the field is not visible or it is locked), we still return true. So this is actually checking if we should redirect the user to edit their profile, rather than whether there is a value in the database.

Parameters
int$userid
Return values
bool

◆ profile_list_categories()

profile_list_categories ( )

Retrieve a list of categories and ids suitable for use in a form.

Return values
array

◆ profile_list_datatypes()

profile_list_datatypes ( )

Retrieve a list of all the available data types.

Return values
arraya list of the datatypes suitable to use in a select statement

◆ profile_load_custom_fields()

profile_load_custom_fields (   $user)

Load custom profile fields into user object.

Parameters
stdClass$useruser object

◆ profile_load_data()

profile_load_data (   $user)

Loads user profile field data into the user object.

Parameters
stdClass$user

◆ profile_move_category()

profile_move_category (   $id,
  $move 
)

Change the sort order of a category.

Parameters
int$idof the category
string$movedirection of move
Return values
boolsuccess of operation

◆ profile_move_field()

profile_move_field (   $id,
  $move 
)

Change the sort order of a field.

Parameters
int$idof the field
string$movedirection of move
Return values
boolsuccess of operation

◆ profile_save_custom_fields()

profile_save_custom_fields (   $userid,
  $profilefields 
)

Save custom profile fields for a user.

Parameters
int$useridThe user id
array$profilefieldsThe fields to save

◆ profile_save_data()

profile_save_data (   $usernew)

Saves profile data for a user.

Parameters
stdClass$usernew

◆ profile_signup_fields()

profile_signup_fields (   $mform)

Adds code snippet to a moodle form object for custom profile fields that should appear on the signup page.

Parameters
moodleform$mformmoodle form object

◆ profile_user_record()

profile_user_record (   $userid,
  $onlyinuserobject = true 
)

Returns an object with the custom profile fields set for the given user.

Parameters
integer$userid
bool$onlyinuserobjectTrue if you only want the ones in $USER.
Return values
stdClass

◆ profile_validation()

profile_validation (   $usernew,
  $files 
)

Validates profile data.

Parameters
stdClass$usernew
array$files
Return values
array

◆ profile_view()

profile_view (   $user,
  $context,
  $course = null 
)

Trigger a user profile viewed event.

Parameters
stdClass$useruser object
stdClass$contextcontext object (course or user)
stdClass$coursecourse object
Since
Moodle 2.9

◆ user_add_password_history()

user_add_password_history (   $userid,
  $password 
)

Add password to the list of used hashes for this user.

This is supposed to be used from: 1/ change own password form 2/ password reset process 3/ user signup in auth plugins if password changing supported

Parameters
int$useriduser id
string$passwordplaintext password
Return values
void

◆ user_can_view_profile()

user_can_view_profile (   $user,
  $course = null,
  $usercontext = null 
)

Check if the current user has permission to view details of the supplied user.

This function supports two modes: If the optional $course param is omitted, then this function finds all shared courses and checks whether the current user has permission in any of them, returning true if so. If the $course param is provided, then this function checks permissions in ONLY that course.

Parameters
object$userThe other user's details.
object$courseif provided, only check permissions in this course.
context$usercontextThe user context if available.
Return values
booltrue for ability to view this user, else false.

◆ user_convert_text_to_menu_items()

user_convert_text_to_menu_items (   $text,
  $page 
)

Converts a string into a flat array of menu items, where each menu items is a stdClass with fields type, url, title, pix, and imgsrc.

Parameters
string$textthe menu items definition
moodle_page$pagethe current page
Return values
array

◆ user_count_login_failures()

user_count_login_failures (   $user,
  $reset = true 
)

Count the number of failed login attempts for the given user, since last successful login.

Parameters
int | stdclass$useruser id or object.
bool$resetResets failed login count, if set to true.
Return values
intnumber of failed login attempts since the last successful login.

◆ user_create_user()

user_create_user (   $user,
  $updatepassword = true,
  $triggerevent = true 
)

Creates a user.

Exceptions
moodle_exception
Parameters
stdClass$useruser to create
bool$updatepasswordif true, authentication plugin will update password.
bool$triggereventset false if user_created event should not be triggred. This will not affect user_password_updated event triggering.
Return values
intid of the newly created user

◆ user_delete_user()

user_delete_user (   $user)

Marks user deleted in internal user database and notifies the auth plugin.

Also unenrols user from all roles and does other cleanup.

Todo:
Decide if this transaction is really needed (look for internal TODO:)
Parameters
object$userUserobject before delete (without system magic quotes)
Return values
booleansuccess

◆ user_edit_map_field_purpose()

user_edit_map_field_purpose (   $userid,
  $fieldname 
)

Map an internal field name to a valid purpose from: "https://www.w3.org/TR/WCAG21/#input-purposes".

Parameters
integer$userid
string$fieldname
Return values
string::$purpose(empty string if there is no mapping).

◆ user_get_course_lastaccess_sql()

user_get_course_lastaccess_sql (   $accesssince = null,
  $tableprefix = 'ul' 
)

Returns SQL that can be used to limit a query to a period where the user last accessed a course.

Parameters
int$accesssinceThe time since last access
string$tableprefix
Return values
string

◆ user_get_default_fields()

user_get_default_fields ( )

Returns the list of default 'displayable' fields.

Contains database field names but also names used to generate information, such as enrolledcourses

Return values
arrayof user fields

◆ user_get_participants()

user_get_participants (   $courseid,
  $groupid = 0,
  $accesssince,
  $roleid,
  $enrolid = 0,
  $statusid,
  $search,
  $additionalwhere = '',
  $additionalparams = array(),
  $sort = '',
  $limitfrom = 0,
  $limitnum = 0 
)

Returns the participants for a given course.

Parameters
int$courseidThe course id
int$groupidThe groupid, 0 means all groups and USERSWITHOUTGROUP no group
int$accesssinceThe time since last access
int$roleidThe role id
int$enrolidThe applied filter for the user enrolment ID.
int$statusThe applied filter for the user's enrolment status.
string$searchThe search that was performed
string$additionalwhereAny additional SQL to add to where
array$additionalparamsThe additional params
string$sortThe SQL sort
int$limitfromreturn a subset of records, starting at this point (optional).
int$limitnumreturn a subset comprising this many records (optional, required if $limitfrom is set).
Return values
moodle_recordset

◆ user_get_participants_sql()

user_get_participants_sql (   $courseid,
  $groupid = 0,
  $accesssince = 0,
  $roleid = 0,
  $enrolid = 0,
  $statusid = -1,
  $search = '',
  $additionalwhere = '',
  $additionalparams = array() 
)

Returns the SQL used by the participants table.

Parameters
int$courseidThe course id
int$groupidThe groupid, 0 means all groups and USERSWITHOUTGROUP no group
int$accesssinceThe time since last access, 0 means any time
int$roleidThe role id, 0 means all roles and -1 no roles
int$enrolidThe enrolment id, 0 means all enrolment methods will be returned.
int$statusidThe user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed.
string | array$searchThe search that was performed, empty means perform no search
string$additionalwhereAny additional SQL to add to where
array$additionalparamsThe additional params
Return values
array

◆ user_get_tagged_users()

user_get_tagged_users (   $tag,
  $exclusivemode = false,
  $fromctx = 0,
  $ctx = 0,
  $rec = 1,
  $page = 0 
)

Returns users tagged with a specified tag.

Parameters
core_tag_tag$tag
bool$exclusivemodeif set to true it means that no other entities tagged with this tag are displayed on the page and the per-page limit may be bigger
int$fromctxcontext id where the link was displayed, may be used by callbacks to display items in the same context first
int$ctxcontext id where to search for records
bool$recsearch in subcontexts as well
int$page0-based number of page being displayed
Return values
core_tag

◆ user_get_total_participants()

user_get_total_participants (   $courseid,
  $groupid = 0,
  $accesssince = 0,
  $roleid = 0,
  $enrolid = 0,
  $statusid = -1,
  $search = '',
  $additionalwhere = '',
  $additionalparams = array() 
)

Returns the total number of participants for a given course.

Parameters
int$courseidThe course id
int$groupidThe groupid, 0 means all groups and USERSWITHOUTGROUP no group
int$accesssinceThe time since last access, 0 means any time
int$roleidThe role id, 0 means all roles
int$enrolidThe applied filter for the user enrolment ID.
int$statusThe applied filter for the user's enrolment status.
string | array$searchThe search that was performed, empty means perform no search
string$additionalwhereAny additional SQL to add to where
array$additionalparamsThe additional params
Return values
int

◆ user_get_user_details()

user_get_user_details (   $user,
  $course = null,
array  $userfields = array() 
)

Give user record from mdl_user, build an array contains all user details.

Warning: description file urls are 'webservice/pluginfile.php' is use. it can be changed with $CFG->moodlewstextformatlinkstoimagesfile

Exceptions
moodle_exception
Parameters
stdClass$useruser record from mdl_user
stdClass$coursemoodle course
array$userfieldsrequired fields
Return values
array|null

◆ user_get_user_details_courses()

user_get_user_details_courses (   $user)

Tries to obtain user details, either recurring directly to the user's system profile or through one of the user's course enrollments (course profile).

Parameters
stdClass$userThe user.
Return values
arrayif unsuccessful or the allowed user details.

◆ user_get_user_lastaccess_sql()

user_get_user_lastaccess_sql (   $accesssince = null,
  $tableprefix = 'u' 
)

Returns SQL that can be used to limit a query to a period where the user last accessed the system.

Parameters
int$accesssinceThe time since last access
string$tableprefix
Return values
string

◆ user_get_user_navigation_info()

user_get_user_navigation_info (   $user,
  $page,
  $options = array() 
)

Get a list of essential user navigation items.

Parameters
stdclass$useruser object.
moodle_page$pagepage object.
array$optionsassociative array. options are:
  • avatarsize=35 (size of avatar image)
Return values
stdClass::$returnobjnavigation information object, where:
 $returnobj->navitems    array    array of links where each link is a
                                  stdClass with fields url, title, and
                                  pix
 $returnobj->metadata    array    array of useful user metadata to be
                                  used when constructing navigation;
                                  fields include:

     ROLE FIELDS
     asotherrole    bool    whether viewing as another role
     rolename       string  name of the role

     USER FIELDS
     These fields are for the currently-logged in user, or for
     the user that the real user is currently logged in as.

     userid         int        the id of the user in question
     userfullname   string     the user's full name
     userprofileurl moodle_url the url of the user's profile
     useravatar     string     a HTML fragment - the rendered
                               user_picture for this user
     userloginfail  string     an error string denoting the number
                               of login failures since last login

     "REAL USER" FIELDS
     These fields are for when asotheruser is true, and
     correspond to the underlying "real user".

     asotheruser        bool    whether viewing as another user
     realuserid         int        the id of the user in question
     realuserfullname   string     the user's full name
     realuserprofileurl moodle_url the url of the user's profile
     realuseravatar     string     a HTML fragment - the rendered
                                   user_picture for this user

     MNET PROVIDER FIELDS
     asmnetuser            bool   whether viewing as a user from an
                                  MNet provider
     mnetidprovidername    string name of the MNet provider
     mnetidproviderwwwroot string URL of the MNet provider

◆ user_get_users_by_id()

user_get_users_by_id (   $userids)

Get users by id.

Parameters
array$useridsid of users to retrieve
Return values
array

◆ user_is_previously_used_password()

user_is_previously_used_password (   $userid,
  $password 
)

Was this password used before on change or reset password page?

The $CFG->passwordreuselimit setting determines how many times different password needs to be used before allowing previously used password again.

Parameters
int$useriduser id
string$passwordplaintext password
Return values
booltrue if password reused

◆ user_list_view()

user_list_view (   $course,
  $context 
)

Trigger user_list_viewed event.

Parameters
stdClass$coursecourse object
stdClass$contextcourse context object
Since
Moodle 2.9

◆ user_mygrades_url()

user_mygrades_url (   $userid = null,
  $courseid = SITEID 
)

Returns the url to use for the "Grades" link in the user navigation.

Parameters
int$useridThe user's ID.
int$courseidThe course ID if available.
Return values
mixedA URL to be directed to for "Grades".

◆ user_page_type_list()

user_page_type_list (   $pagetype,
  $parentcontext,
  $currentcontext 
)

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block
Return values
array

◆ user_remove_user_device()

user_remove_user_device (   $uuid,
  $appid = "" 
)

Remove a user device from the Moodle database (for PUSH notifications usually).

Parameters
string$uuidThe device UUID.
string$appidThe app id. If empty all the devices matching the UUID for the user will be removed.
Return values
booltrue if removed, false if the device didn't exists in the database
Since
Moodle 2.9

◆ user_update_user()

user_update_user (   $user,
  $updatepassword = true,
  $triggerevent = true 
)

Update a user with a user object (will compare against the ID)

Exceptions
moodle_exception
Parameters
stdClass$userthe user to update
bool$updatepasswordif true, authentication plugin will update password.
bool$triggereventset false if user_updated event should not be triggred. This will not affect user_password_updated event triggering.

◆ useredit_get_disabled_name_fields()

useredit_get_disabled_name_fields (   $enabledadditionalusernames = null)

Gets user name fields not enabled from the setting fullnamedisplay.

Parameters
array$enabledadditionalusernamesCurrent enabled additional user name fields.
Return values
arrayDisabled user name fields.

◆ useredit_get_enabled_name_fields()

useredit_get_enabled_name_fields ( )

Gets enabled (from fullnameformate setting) user name fields in appropriate order.

Return values
arrayEnabled user name fields.

◆ useredit_get_required_name_fields()

useredit_get_required_name_fields ( )

Return required user name fields for forms.

Return values
arrayrequired user name fields in order according to settings.

◆ useredit_load_preferences()

useredit_load_preferences ( $user,
  $reload = true 
)

Loads the given users preferences into the given user object.

Parameters
stdClass$userThe user object, modified by reference.
bool$reload

◆ useredit_setup_preference_page()

useredit_setup_preference_page (   $userid,
  $courseid 
)

Performs the common access checks and page setup for all user preference pages.

Parameters
int$useridThe user id to edit taken from the page params.
int$courseidThe optional course id if we came from a course context.
Return values
arraycontaining the user and course records.

◆ useredit_shared_definition()

useredit_shared_definition ( $mform,
  $editoroptions,
  $filemanageroptions,
  $user 
)

Powerful function that is used by edit and editadvanced to add common form elements/rules/etc.

Parameters
moodleform$mform
array$editoroptions
array$filemanageroptions
stdClass$user

◆ useredit_update_bounces()

useredit_update_bounces (   $user,
  $usernew 
)

Updates the user email bounce + send counts when the user is edited.

Parameters
stdClass$userThe current user object.
stdClass$usernewThe updated user object.

◆ useredit_update_interests()

useredit_update_interests (   $user,
  $interests 
)

Updates a users interests.

Parameters
stdClass$user
array$interests

◆ useredit_update_picture()

useredit_update_picture ( )
Deprecated:
since Moodle 3.2
See also
core_user::update_picture()

◆ useredit_update_trackforums()

useredit_update_trackforums (   $user,
  $usernew 
)

Updates the forums a user is tracking when the user is edited.

Parameters
stdClass$userThe original user object.
stdClass$usernewThe updated user object.

◆ useredit_update_user_preference()

useredit_update_user_preference (   $usernew)

Updates the user preferences for the given user.

Only preference that can be updated directly will be updated here. This method is called from various WS updating users and should be used when updating user details. Plugins may whitelist preferences that can be updated by defining 'user_preferences' callback, {

See also
core_user::fill_preferences_cache()}

Some parts of code may use user preference table to store internal data, in these cases it is acceptable to call set_user_preference()

Parameters
stdClass | array$usernewobject or array that has user preferences as attributes with keys starting with preference_

Variable Documentation

◆ PROFILE_VISIBLE_ALL

const PROFILE_VISIBLE_ALL '2'

Visible to anyone who can view the user.

Editable by the profile owner if they have the moodle/user:editownprofile capability or any user with the moodle/user:update capability.

◆ PROFILE_VISIBLE_NONE

const PROFILE_VISIBLE_NONE '0'

Only visible to users with the moodle/user:viewalldetails capability.

Only editable by users with the moodle/user:viewalldetails and moodle/user:update capabilities.

◆ PROFILE_VISIBLE_PRIVATE

const PROFILE_VISIBLE_PRIVATE '1'

Visible to the profile owner or anyone with the moodle/user:viewalldetails capability.

Editable by the profile owner if they have the moodle/user:editownprofile capability or any user with moodle/user:viewalldetails and moodle/user:update capabilities.