0

I've been changing the name of the "Posts" to something else with the following code:

// Change menu labels
function xxx_admin_menus() {
    global $menu;
    global $submenu;

    $menu[5][0] = 'Nyheter'; // Change Posts to Nyheter
    $submenu['edit.php'][5][0] = 'Alla nyheter';
    $submenu['edit.php'][10][0] = 'Ny nyhet';
}
add_action( 'admin_menu', 'xxx_admin_menus' );

This works. However, if a user that logs in does not have the edit_posts capability, the dashboard get's wrecked with error messages.

Is there a better way to change menu item names without this happening?

0

It can not work for user roles that don't see and don't have access to the menu section. It just is not there - for them -, so you can't address it, hence the errors you are getting. Just add a check:

if( current_user_can( 'edit_posts' ) ) { 
  //code 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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