How To Remove or Hide Appearance->Background from Admin Menu

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

Topic theme-customizer admin-menu Wordpress

Category Web


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' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.