I am attempting to convert subuser_switch to use masquerade as I think it makes more sense, but I think having the following feature is a must and works better for most projects I have used this on.

 * Implements hook_menu_link_alter().
 * @see subuser_switch_translated_menu_link_alter()
function subuser_switch_menu_link_alter(&$item) {
  // Allow the logout link to be altered.
  if ($item['link_path'] == 'user/logout') {
    $item['options']['alter'] = TRUE;

 * Implements hook_translated_menu_link_alter().
function subuser_switch_translated_menu_link_alter(&$item, $map) {
  // If currently running as a child user change the "Log out" link to
  // "Log out (return)".
  if ($item['href'] == 'user/logout' && !empty($_SESSION['subuser_parent'])) {
    $item['title'] = t('Log out (return)');
    $item['href'] = 'subuser/switch/' . $_SESSION['subuser_parent'];
#1 1146452-link.patch1.12 KBboombatower
Members fund testing for the Drupal project. Drupal Association Learn more


boombatower’s picture

Status: Active » Needs review
1.12 KB

Rough conversion. Still needs setting (or replace current method of additional menu item) and token jazz.

andypost’s picture

Status: Needs review » Needs work

I'm not sure about UX of this - some modules are altering the logout link to implement protection
also this patch needs token support