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

How to remove the "My account" link

Posted on May 15, 2008 - 4:22pm
<< 38 of 54 >>

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?

Submitted by leather g-string (not verified) on January 9, 2011 - 11:36pm.

Good way of blogging, Keep up the work going.

Submitted by toller maill (not verified) on July 27, 2011 - 10:49pm.

It is my first time visiting here. I found so many exciting stuff within your blog especially the ongoing talk. From the tons of comments on your posts, I assume I am not the only one taking pleasure in looking through your website. Carry on the great work.
online marketing

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.