1

I have a menu Appearance->Background on WP admin, i want to remove or hide from Editor user. i was try to using

public function remove_menu()
if( !current_user_can( 'administrator' )){
{
   if( !current_user_can( 'administrator' ))
   {
        remove_submenu_page( 'themes.php', 'background.php');
   }
}

add_action('admin_init', [$this,'remove_menu']);

But the menu still appear, what solution for this?Thanks

0

Try adding a filter instead. See this answer for more details

add_filter('admin_menu', 'admin_menu_filter',500);
function admin_menu_filter(){
   if (! is_admin()){
       remove_submenu_page( 'themes.php', 'background.php');
   }
}

Also double check your link to the page from the admin menu. More details in the Wordpress Codex

To remove a settings page for plugins that use a slug like /wp-admin/options-general.php?page=certain-plugin-settings use this code:....remove_submenu_page( 'options-general.php', 'certain-plugin-settings' );

| improve this answer | |

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.