getLoginUserName

Skip to end of metadata
Go to start of metadata

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!";

Related

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'];
        }
    }
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.