getLoginUserName

Last edited by JP DeVries on Aug 10, 2013.

API:getLoginUserName

API Quick reference
Variable name: getLoginUserName
Modx versions: 0.9.x + Evolution
Input parameters:  
Return if successful: Logged in user ID
Return type: mixed
Return on failure: null
Object parent: DocumentParser

Description / Usage

mixed getLoginUserName();

Determines if user is logged in, be it via Manager Interface, or Web Interface, and returns an string with the User Name of the current user. If no user is logged in, null is returned.

Examples

echo ($modx->getLoginUserName)?"Hello, ".$modx->getLoginUserName()."!":"Hello, Guest!";

Notes

In the manager, the value returned will be the manager user's username.

Function Source

File: manager/includes/document.parser.class.inc.php
Line: 2028

function getLoginUserName() {
        if ($this->isFrontend() && isset ($_SESSION['webValidated'])) {
            return $_SESSION['webShortname'];
        }
        elseif ($this->isBackend() && isset ($_SESSION['mgrValidated'])) {
            return $_SESSION['mgrShortname'];
        }
    }

Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).