Pedro Posada | How to remove the "My account" link

How to remove the "My account" link

Posted on May 15, 2008 - 4:22pm
<< 30 of 46 >>

This php snippet is useful for customizing the behavior of the "My account" link. Sometimes you want to place a login link in one of the menus. It might be confusing sometimes because after you login, the link won't show as "Logout" but as "My account". This is not ideal so you can use the snippet to make it show as "Logout". Place this code inside your template.php file.

<?php
/**
* Override the primary links theming and alter the 'My account' menu item.
*/

function phptemplate_links($links_array,$links_class) {

    foreach(
$links_array as $key => $link) {
        if (
$link['title']=='My account') {

           
/**
             * Use this code if you want to change the 'My account' menu item to a logout menu item.
             * Be sure to leave your users some way to get their user page!
             */
            //$link['title'] = 'log out';
            //$link['href'] = 'logout';

            /**
             * Use this code if you want to change the text of the 'My account' menu item to the user's username
             */
            //global $user;
            //$link['title'] = $user->name;
  
            /**
             * Use this code if you want to remove the 'My account' menu item altogether.
             */
            
unset($links_array[$key]);
        }

       
$links_array[$key] = $link;
    }
  
    return
theme_links($links_array,$links_class);
}
?>
Go to http://drupal.org/node/68792 to find good info on how to remove unwanted tabs. 

Submitted by Chad (not verified) on July 15, 2008 - 5:05pm.

Great snippet. Appreciate this !

Submitted by aoc gold (not verified) on October 7, 2008 - 3:47am.

The My Account menu item is locked to the navigation menu.

Create a new menu and move everything from the navigation menu to the new menu. Been doing that for years with most of my sites.

Drupal 7 may bring a different way of handling this.

Submitted by aoc gold (not verified) on February 20, 2009 - 2:09am.

I want to remove both links 'Logout' and 'My Account' from the top navigation header when I'm login. My Account and Checkout pages became 'crazy' because of that. How to remove it?

Post new comment

The content of this field is kept private and will not be shown publicly.
Please solve the math question. This way we will know you are not a robot.