How to redirect users after login to custom resources based on user group and assigned resource group dynamically? I will have a lot of users and each one will have a user group with their unique resource group.
So each user when logged in should be redirected to their specific resource which is hidden from other users (their personal page). Each user has its own user group and resource group (with specific resource) assigned to its user group. I can’t hardcode redirect in login page since there is going to be more users added in the future. Searched the net for solution, but couldn’t find similar situation where’s that dynamicaly solved. It’s modx Revolution 3.0.4-pl! Any chance for help @bobray ? Thank you!
This is what I’ve tried so far snippet that is called &postHooks=landingPage
<?php
$userId = $modx->getUser()->get('id');
// Get the resource ID assigned to the user's group
$resourceId = $modx->getOption('resource_id', $scriptProperties);
// Check if the user has access to the specified resource
if ($modx->hasPermission('resource_view', $resourceId)) {
// Redirect the user to the specific resource
$modx->sendRedirect($modx->makeUrl($resourceId));
} else {
// Redirect to a default page or handle as needed
$modx->sendRedirect($modx->makeUrl(2)); // Change 1 to the default resource ID
}