For anyone interested this is how to log a member out automatically in a non-member area:
This is currently configured to only work for the home page.
Put the following snippet call before any code into the non-member area template:
[[logoutSnippet]]
Create a weblink with the external link as the home page of your site. i.e.
http://www.yoursite.com/
Then create the following snippet titled logoutSnippet (There is probably way too much code in my snippet but I don’t have the time to clean it up!)
<?php
$type = isset($type) ? $type : 'simple';
$regType = isset($regType) ? $regType : 'instant';
$notify = isset($notify) ? $notify : '';
$groups = isset($groups) ? $groups : '';
$regRequired = isset($regRequired) ? $regRequired : '';
$customTable = isset($customTable) ? $customTable : 'web_user_attributes_extended';
$customFields = isset($customFields) ? $customFields : '';
$prefixTable = isset($prefixTable) ? $prefixTable : 1;
$lang = isset($lang) ? $lang : 'en';
$userImageSettings = isset($userImage) ? $userImage : '105000,100,100';
$dateFormat = isset($dateFormat) ? $dateFormat : '%A %B %d, %Y at %I:%M %p';
$disableServices = isset($disableServices) ? explode(',', str_replace(', ',',',$disableServices)) : array();
$tableCheck = isset($tableCheck) ? $tableCheck : 1;
include_once MODX_BASE_PATH.'assets/snippets/webloginpe/webloginpe.class.php';
include MODX_BASE_PATH.'assets/snippets/webloginpe/webloginpe.templates.php';
if (file_exists(MODX_BASE_PATH.'assets/snippets/webloginpe/lang/'.$lang.'.php'))
{
include_once MODX_BASE_PATH.'assets/snippets/webloginpe/lang/'.$lang.'.php';
}
else
{
include_once MODX_BASE_PATH.'assets/snippets/webloginpe/lang/en.php';
$modx->setPlaceholder('wlpe.message', $wlpe_lang[105]);
print '[+wlpe.message+]';
}
$wlpe = new WebLoginPE($wlpe_lang, $dateFormat, $userImageSettings, $type);
$wlpe->CustomTable($customTable, $customFields, $prefixTable, $tableCheck);
$liHomeId = isset($liHomeId) ? explode(',', $liHomeId) : '';
$loHomeId = isset($loHomeId) ? $loHomeId : '';
$regHomeId = isset($regHomeId) ? $regHomeId : '';
$regSuccessId = isset($regSuccessId) ? $regSuccessId : '';
$regSuccessPause = isset($regSuccessPause) ? $regSuccessPause : 5;
$profileHomeId = isset($profileHomeId) ? $profileHomeId : '';
$inputHandler = isset($inputHandler) ? explode('||', $inputHandler) : array();
$usersList = isset($usersList) ? $usersList : '';
if ($regType == 'verify'){$wlpeRegisterTpl = $wlpeRegisterVerifyTpl;}else{$wlpeRegisterTpl = $wlpeRegisterInstantTpl;}
$displayLoginFormTpl = isset($loginFormTpl) ? $wlpe->Template($loginFormTpl) : $wlpeDefaultFormTpl;
$displaySuccessTpl = isset($successTpl) ? $wlpe->Template($successTpl) : $wlpeDefaultSuccessTpl;
$displayRegisterTpl = isset($registerTpl) ? $wlpe->Template($registerTpl) : $wlpeRegisterTpl;
$displayRegSuccessTpl = isset($registerSuccessTpl) ? $wlpe->Template($registerSuccessTpl) : $wlpeDefaultFormTpl;
$displayProfileTpl = isset($profileTpl) ? $wlpe->Template($profileTpl) : $wlpeProfileTpl;
$displayViewProfileTpl = isset($viewProfileTpl) ? $wlpe->Template($viewProfileTpl) : $wlpeViewProfileTpl;
$displayUsersOuterTpl = isset($usersOuterTpl) ? $wlpe->Template($usersOuterTpl) : $wlpeUsersOuterTpl;
$displayUsersTpl = isset($usersTpl) ? $wlpe->Template($usersTpl) : $wlpeUsersTpl;
$displayManageOuterTpl = isset($manageOuterTpl) ? $wlpe->Template($manageOuterTpl) : $wlpeUsersOuterTpl;
$displayManageTpl = isset($manageTpl) ? $wlpe->Template($manageTpl) : $wlpeManageTpl;
$displayManageProfileTpl = isset($manageProfileTpl) ? $wlpe->Template($manageProfileTpl) : $wlpeManageProfileTpl;
$displayManageDeleteTpl = isset($manageDeleteTpl) ? $wlpe->Template($manageDeleteTpl) : $wlpeManageDeleteTpl;
$displayProfileDeleteTpl = isset($profileDeleteTpl) ? $wlpe->Template($profileDeleteTpl) : $wlpeProfileDeleteTpl;
$displayActivateTpl = isset($activateTpl) ? $wlpe->Template($activateTpl) : $wlpeActivateTpl;
$displayResetTpl = isset($resetTpl) ? $wlpe->Template($resetTpl) : $wlpeResetTpl;
$notifyTpl = isset($notifyTpl) ? $wlpe->Template($notifyTpl) : $wlpeNotifyTpl;
$notifySubject = isset($notifySubject) ? $notifySubject : 'New Web User for '.$modx->config['site_name'].'.';
$messageTpl = isset($messageTpl) ? $wlpe->Template($messageTpl) : $wlpeMessageTpl;
$tosChunk = isset($tosChunk) ? $wlpe->Template($tosChunk) : $wlpeTos;
$modx->setPlaceholder('tos', $tosChunk);
$loadJquery = isset($loadJquery) ? $loadJquery : false;
$customJs = isset($customJs) ? $customJs : '';
$user_id = $modx->getLoginUserID();
if ($user_id) {
// somebody's logged in
$wlpe->Logout($type, $loHomeId);
return $displayLoginFormTpl;
$go_url = $modx->makeUrl(78);
$modx->sendRedirect($go_url);
}
?>
Notice the third last line:
$go_url = $modx->makeUrl(78);
78 was the page ID number for my weblink. PLace your weblink ID here,
Hope this helps anyone, its a pretty messy solution really but Im still learning
Regards,
Global