This question has been answered by microcipcip. See the first response.
<?php /* See if the page visitor is a logged in web user or manager user */ $userName = $modx->getLoginUserName(); return $userName; ?>
[[username]]
<?php #:::::::::::::::::::::::::::::::::::::::: # Snippet Name: CheckLogin # Short Desc: Checks if a user is logged in and returns a linktext accordingly # Version: 0.1 # Created By: Wim Beerens ([email protected]) # # Date: November 26, 2006 # # Changelog: # November 26, 2006 -- initial release # #:::::::::::::::::::::::::::::::::::::::: # Usage: # Checks if a user is logged in and returns a linktext accordingly # Snippet based on Personalize and WebLogin snippet # To be used uncached only # # Installation: # In the Manager create a new snipped called CheckLogin # and copy/paste this code into the new snippet # For ease of use click on the tab Properties # and copy/paste the following code into the Default Properties Field: # &logintext=Login link text;string; &logouttext=Logout link text;string; # # Params: # # &logintext [string] (optional) # Linktext to be displayed when user is logged out (!) # # &logouttext [string] (optional) # Linktext to be displayed when user is logged in (!) # # # Examples: # # [!CheckLogin!] # # [!CheckLogin? &logintext=`Loginpage` &logouttext=`Logoutpage`!] # #:::::::::::::::::::::::::::::::::::::::: # check if inside manager if ($m = $modx->insideManager()) { return ''; # don't go any further when inside manager } # Snippet customize settings $loginText = isset($logintext)? $logintext:'Login'; $logoutText = isset($logouttext)? $logouttext:'Logout'; # Check if user is logged in $output = ''; $test = $modx->getLoginUserName(); if ($test == '') { $output = $loginText; } else { $output = $logoutText; } return $output; ?>
[!checklogin? &logintext=`LOGIN TEXT` &logouttext=`LOGOUT TEXT Welcome [[username]]`!]
[!checklogin? &logintext=`LOGIN TEXT` &logouttext=`LOGOUT TEXT Welcome [[username]]`!]
No, like this:So is this the Uncached version then?
[!checklogin? &logintext=`LOGIN TEXT` &logouttext=`LOGOUT TEXT Welcome [[username]]`!]