I have a plugin that fires OnManagerLogin. In the plugin's code I am trying to get a modContext object, but it fails with a message along the lines of "Principal 0 does not have permission to load object of class modContext with primary key: mycontextkey".
I've debugged through to this error message and it looks like the $user var sent to the event is indeed the user that just logged in, but $modx->user is still anonymous (hence the "Principal 0" in the error message).
I'm trying to access the context like this:
$ctx = $modx->getContext('mycontextkey);
I'm pretty sure it's not an ACL issue, as I have got around the problem by using the OnManagerPageInit event. At this point the code above
does work, and I can get the context I want. I'm currently just setting a session var when my logic is complete and then checking for that before running it to prevent doing it on every page load (I only need it once per session).
Is this possibly part of the bugs alluded to in these posts:
https://forums.modx.com/index.php?topic=61831.0 or
https://forums.modx.com/thread/?thread=28559&page=1, or am I missing something about the order of events?