You can get alot of logged in user info from the SESSION to use in your snippets. Note that the admin (back end) and web users (front end) are seperate, so you have to create a web user account for yourself (if you haven’t already).
Make you a new snippet named Session_Info with the following code, call it in a document ( [!Session_Info!] ), log in to either the manager(admin) or as a web user (or both), navigate to that page and it will show you whats available.
<?php
/* Session_Info
[!Session_Info!]
*/
$output = print_r($_SESSION);
return $output;
?>
edit: A quick example of using existing session variables in a snippet:
<?php
/* WebUser_Redirect
*/
$output ="";
if(isset($_SESSION['webValidated']) && isset($_SESSION['webShortname'])){
$web_UserLoginHomeID =$_SESSION[webUsrConfigSet][login_home];
if($web_UserLoginHomeID !=""){
// grab the current page id and compare to the users home id
// if it matches then print something, if not it creates the link or placeholder
$currentdoc = $modx->documentIdentifier;
if($currentdoc == $web_UserLoginHomeID){
// in this example it prints: Breezer's Home Page (Breezer would be the logged users name)
$output .=$_SESSION['webShortname']."'s Home Page";
}else{
// output a simple text link wherever this snippet is placed
$output .="<a href='[~".$web_UserLoginHomeID."~]'>Home Page</a>";
// or set a placeholder to use in the script later
$output .= $modx->setPlaceholder("WULoginHomeID", "$web_UserLoginHomeID"); // [+WULoginHomeID+]
// example of placeholder usage
$output .="<a href='[~[+WULoginHomeID+]~]'>Home Page</a>";
}
}
}
return $output;
?>