user_support
class user_support
| internal |
Utility functions for Moodle users and custom profile fields.
Methods
Retrieves a custom profile field value for a user.
Retrieves a list of user fields available for selection.
Retrieves all custom profile fields.
Retrieves a specific user profile data record.
Retrieves profile field information or user data by shortname.
Saves a custom profile field value for a specific user.
Retrieves a user by their email address.
Retrieves a user by their database ID.
Retrieves a user by their username.
Creates a new Moodle user with sensible defaults.
Updates an existing Moodle user.
Retrieves the full name of a user.
Retrieves the current logged-in user ID.
Retrieves the current user entity.
Details
at line 47
static mixed
get_field_by_user(int|string $fieldidorshortname, int|null $userid = null)
Retrieves a custom profile field value for a user.
at line 85
static array
get_options_for_user_fields(bool $includeemailfield = false)
Retrieves a list of user fields available for selection.
at line 120
static array
get_all_profile_fields()
Retrieves all custom profile fields.
at line 139
static false|stdClass|null
get_user_field(int $fieldid, int|null $userid = null)
Retrieves a specific user profile data record.
at line 182
static false|int|stdClass|null
get_user_field_data_by_shortname(string $shortname, int|null $userid = null)
Retrieves profile field information or user data by shortname.
If $userid is null/0, returns the field ID (int). If $userid is provided, returns the user data record (stdClass).
at line 222
static void
save_profile_fields(int $userid, int|string $fieldidorshortname, string $value)
Saves a custom profile field value for a specific user.
at line 252
static user|null
get_user_by_email(string $email, string $fields = '*', int|null $mnethostid = null, int $strictness = IGNORE_MISSING)
Retrieves a user by their email address.
at line 268
static user|null
get_user(int $userid, string $fields = '*', int $strictness = IGNORE_MISSING)
Retrieves a user by their database ID.
at line 284
static user|null
get_user_by_username(string $username, int|null $mnethostid = null, int $strictness = IGNORE_MISSING)
Retrieves a user by their username.
at line 300
static int
create_user(stdClass $userobj, bool $updatepassword = false, bool $nologin = false)
Creates a new Moodle user with sensible defaults.
at line 327
static void
update_user(stdClass $userobj, bool $updatepassword = true, bool $triggerevent = true)
Updates an existing Moodle user.
at line 343
static bool
delete_user(stdClass $user)
Soft-deletes a user.
at line 359
static string
fullname(user $user)
Retrieves the full name of a user.
at line 371
static int
get_current_user_id()
Retrieves the current logged-in user ID.
at line 383
static user|null
get_current()
Retrieves the current user entity.