Untitled
unknown
plain_text
a year ago
844 B
2
Indexable
use Symfony\Component\HttpFoundation\RedirectResponse; /** * Implements hook_menu_alter(). */ function custom_homepage_role_menu_alter(&$items) { global $user; $desired_roles = ['IS', 'MMS', 'AA IS']; // Check if the user has any of the desired roles. foreach ($desired_roles as $role) { if (in_array($role, $user->roles)) { // Set the front page path for users with desired roles. $items['<front>']['page callback'] = '_custom_homepage_role_redirect'; break; // Once a matching role is found, exit the loop. } } } /** * Custom callback for redirecting users with desired roles. */ function _custom_homepage_role_redirect() { // Redirect users with desired roles to the custom page. $response = new RedirectResponse('/sr-dashboard'); $response->send(); return; }