Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I can rename wp-admin menu items But How Can I active it for all users except Super Admin ?

add_filter('gettext', 'rename_admin_menu_items');
add_filter('ngettext', 'rename_admin_menu_items');
function rename_admin_menu_items( $menu ) {
$menu = str_ireplace( 'Dashboard', 'Home', $menu );
return $menu;
}
share|improve this question
    
Which hook are you using? –  kaiser Aug 14 '13 at 2:31
    
And where/when does that function run/gets executed? –  kaiser Aug 14 '13 at 11:35
    
I'm sorry I was wrong ,I fixed the code. –  Ghinnersmee Aug 14 '13 at 11:40
2  
Never!, ever hook into gettext, ngettext and similar without instantly removing the attached callbacks! Those filters trigger hundreds of times on each request and can pull your site down to its knees. Seriously. Don't do this. –  kaiser Aug 14 '13 at 11:48
    
thank you ...... –  Ghinnersmee Aug 14 '13 at 12:18
add comment

2 Answers

up vote 1 down vote accepted
/**
 * Changes Label of Admin Menu items
 * @global array $menu
 * @global array $submenu
*/
function change_post_menu_label() {
   global $menu;
   global $submenu;
   $menu[2][0] = 'Home'; 
   $menu[5][0] = 'Articles';
   $submenu['edit.php'][5][0] = "All Articles";
   //    var_dump($submenu);
   //    var_dump($menu);
    echo '';
  }
  if(!is_super_admin()){
    add_action( 'admin_menu', 'change_post_menu_label' );
  }

You can print the array

echo "<pre>";
print_r($menu);
echo "</pre>"; //remove this code after, it is just used to check the index of element in Menu to rename it.

and see elements index to change name for whatever item you'would like to rename. Like in above function I'm renaming the "Posts" in menu to "Articles".

To rename the child of Menu item use

$submenu 

array. For renaming Dashboard to "Home"

  $menu[2][0] = 'Home'; 

add this line to previous function, confirm the index "2" in $menu array for Dashboard.

share|improve this answer
    
thanks bro...how can i rename the "Dashboard" menu to "Home"? –  Ghinnersmee Aug 14 '13 at 11:35
    
I've updated the answer –  sven Aug 14 '13 at 11:47
    
thanks bro ........ –  Ghinnersmee Aug 14 '13 at 12:15
add comment

You need to check the user role. Setup a condition like this:

if(current_user_can("manage_network")) add_action("rename_admin_menu_items","your-hook");

References: User roles

share|improve this answer
    
doesn't work, How should the entire code? –  Ghinnersmee Aug 14 '13 at 11:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.