API:getLoginUserName
From MODx Wiki
API Function Definition:
getLoginUserName
- Versions
- > 0.9.2 ?
- Return Values
- Success: Logged-In User's User Name
- Fail: null
- Data Type
- mixed
- Object Hierarchy
- DocumentParser
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
Related Functions
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']; } }
Example
echo ($modx->getLoginUserName)?"Hello, ".$modx->getLoginUserName()."!":"Hello, Guest!";
Notes
In the manager, the value returned will be the manager user's username.