Example: Remove View and Edit tabs only on user page

Based on this code, I've used this method to remove the 'View' and 'Edit' tabs from my user profile pages. (I should mention that I've also added a bunch of custom tabs already). Here's how I did it...

<?php
 
if (count($local_tasks[$pid]['children'])) {                                                          
    foreach (
$local_tasks[$pid]['children'] as $mid) {  
          
       
// get the name of the tab                              
       
$tab = $local_tasks[$mid]['title'];
      
       
// only remove view & edit tabs if on path = user/uid
       
if (arg(0) == 'user' && is_numeric(arg(1))) {
      
           
// only theme a tab if it is not 'View' or 'Edit'
           
if ($tab != 'View' && $tab != 'Edit') {
                 
$output .= theme('menu_local_task', $mid, menu_in_active_trail($mid), TRUE);
                  }      
                
         
// not on path user/uid so make the tabs as usual
        
} else {
            
$output .= theme('menu_local_task', $mid, menu_in_active_trail($mid), TRUE);
         }
    }
  }
?>

If anyone has suggestions to tighten up the logic in the PHP, please do leave a note.

Hello. I'm trying to remove

lmg1977 - June 21, 2008 - 23:40

Hello.

I'm trying to remove Edit from My Account to registered users, but in witch file do I put this code?

Thanks,

LG

 
 

Drupal is a registered trademark of Dries Buytaert.