<?php
// Gets the analytics if the person is not logged in
// Must call un-cached.
// [[!Get_Analytics]]
$output = '';
$viewer_logged_in = false;
$viewer = $modx->user;
if( $viewer->get('id') != null )
$viewer_logged_in = true;
if($viewer_logged_in == false)
{
$output = 'Put your analytics here, but you will have to escape the apostrophes \' .';
}
else
{
$output = 'You Are Logged In';
}
return $output;
$viewer_logged_in = $modx->user->hasSessionContext($modx->context->get('key'));$viewer_logged_in = $modx->user->hasSessionContext( array('mgr', 'web') );<?php
// Gets the analytics if the person is not logged in
// Must call un-cached.
// [[!Get_Analytics]]
$output = '';
//BobRay from bobsguides.com suggested using this.
$mgr_logged_in = $modx->user->hasSessionContext( 'mgr' );
$web_logged_in = $modx->user->hasSessionContext( 'web' );
if($mgr_logged_in == false && $web_logged_in == false)
{
$output = 'Put your analytics here, but you will have to escape the apostrophes \' .';
}
else
{
$output = 'You\'re logged in as ';
if($mgr_logged_in == true && $web_logged_in == true)
$output .= 'an Admin and User.';
elseif($mgr_logged_in == true && $web_logged_in == false)
$output .= 'an Admin.';
elseif($mgr_logged_in == false && $web_logged_in == true)
$output .= 'a User.';
}
return $output;$mgr_logged_in = $modx->user->hasSessionContext( 'mgr' ); $web_logged_in = $modx->user->hasSessionContext( 'web' ); if($web_logged_in == false) $web_logged_in = $modx->user->hasSessionContext( 'whatiscss' );
It does work great, until you create a Context for use as a subdomain. Then it doesn’t recognize that I’m logged into the manager.
Here is where I tested the different contexts.
$mgr_logged_in = $modx->user->hasSessionContext( 'mgr' ); $web_logged_in = $modx->user->hasSessionContext( 'web' ); if($web_logged_in == false) $web_logged_in = $modx->user->hasSessionContext( 'whatiscss' );
When I go to mysite.com, it will show that I’m logged into the manager, but when I go to whatiscss.mysite.com, it doesn’t recognize that I’m logged into the manager.
(I do wish the Revo API had examples like the old API did. I know, though, that the API is huge and was a huge project to do, thank you Modx team.)
$modx->user->hasSessionContext($modx->context->get('key'))
$modx->user->hasSessionContext($modx->context->get('mgr'))
$modx->user->hasSessionContext($modx->context->get('web'))
$modx->user->hasSessionContext($modx->context->get('adsfadsf'))$modx->user->hasSessionContext('web,mgr');<?php
if ($modx->user->hasSessionContext('web,mgr') || $modx->user->hasSessionContext($modx->context->get('key')) ) {
/* user is logged in somewhere */
}
Okay, so I can figure out if I’m logged into the manager and/or the web context.
However, I can’t seem to see that I’m logged into the manager when I’m at a context other than web. Shouldn’t I be able to tell?
I do appreciate your help. I guess I just want to be able to see exactly where the user is logged in.