Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
core\session\loginas_helper Class Reference

Static Public Member Functions

static get_context_user_can_login_as (stdClass $currentuser, stdClass $loginasuser, ?stdClass $course=null)
 Determine which context a user can login as another user for, given the requested target user and course.
 

Member Function Documentation

◆ get_context_user_can_login_as()

static core\session\loginas_helper::get_context_user_can_login_as ( stdClass $currentuser,
stdClass $loginasuser,
?stdClass $course = null )
static

Determine which context a user can login as another user for, given the requested target user and course.

If the person cannot login at all, then null will be returned.

Parameters
stdClass$currentuserThe current user. Defaults to $USER.
stdClass$loginasuserThe user to be logged in as.
stdClass | null$courseThe course currently being looked at. Applies to those who can only login within a course context. If null, then only system context will be considered.
Return values
context|nullReturns the context that the user is able to login as, or null if no context can be found.

The documentation for this class was generated from the following file: