I'm trying to compare a list of users groups to another list of [Active Directory] groups in a custom table, then store the results in an session variable array so it's handy [and not called a hundred million times!]
The code I have works in a snippet perfectly so far, but as soon as I try to put it in a plugin on the onWebLogin event, it breaks completely.
After a bit of testing, it appears that the logging in user's ID is not yet available when the onWebLogin event fires.... [grrr!]
Any thoughts on which event I can attach this plugin so that it get's executed after the user's id is available?
here's the code:
<?php
$user = $modx->getObject('modUser', $modx->user->get('id'));
$groups = $user->getUserGroupNames();
$sql = "select * from `flow_location`";
$query = $modx->query($sql);
$memberof = array();
if ($query) {
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
if (array_search($row['group'], $groups)){
array_push($memberof, $row);
}
}
}
$_SESSION['memberof'] = $memberof;
echo '<pre>';print_r($_SESSION['memberof']);echo '</pre>';exit();
return;
*** Not just websites, we also create signage, banners, print, trade show displays and more! ***
Sean Kimball CLP, CLS.
Technical Director / Sr. Developer | BigBlock Studios
._______________________________________________.
Bigblock Studios
http://www.bigblockstudios.ca Web site design & development.
27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
phone/fax: 905-426-5525
discuss.answer
Your mistake is using $modx->user.
That works fine in a snippet, but in plugins (including ones attached to OnWebLogin), it's just $user.
Perfect - thanks Bob.
Quote from: BobRay at Mar 13, 2014, 05:11 PMYour mistake is using $modx->user.
That works fine in a snippet, but in plugins (including ones attached to OnWebLogin), it's just $user.
*** Not just websites, we also create signage, banners, print, trade show displays and more! ***
Sean Kimball CLP, CLS.
Technical Director / Sr. Developer | BigBlock Studios
._______________________________________________.
Bigblock Studios
http://www.bigblockstudios.ca Web site design & development.
27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
phone/fax: 905-426-5525