Hide options for specific user/admin


Hide theme options in wordpress for specific user/admin





There are many methods to do so but the effect methods are
Hide theme options in wordpress for specific user/admin
  1. With CSS
  2. With WordPress hide function
You can use any one of the above given method to hide theme options.
But remember that if you use css you have to write css in you function.php no in you css
Syntax of the hiding theme option or any other menu form wp-admin in wordpress with css is given bellow

add_action(‘admin_head’, ‘my_custom_style’);
function my_custom_style() {
echo ‘’;
}
?>
Change the css id and class according your theme ID and Classes
Here is the 2nd method to hide theme option with WordPress built in function function remove_submenu_page. In this function set the user id of a specific user to hide the options
Syntax is given bellow

function hide_menu() {
global $current_user;
$user_id = get_current_user_id();
// echo “user:”.$user_id;   // this will display user id
if($user_id != ‘1’) {
// To remove the whole Appearance admin menu you would use;
remove_menu_page( ‘themes.php’ );
// To remove the theme editor and theme options submenus from
// the Appearance admin menu, as well as the main ‘Themes’
// submenu you would use
remove_submenu_page( ‘themes.php’, ‘themes.php’ );
remove_submenu_page( ‘themes.php’, ‘theme-editor.php’ );
remove_submenu_page( ‘themes.php’, ‘theme_options’ );
remove_submenu_page( ‘themes.php’, ‘_options’ );
}
}
add_action(‘admin_head’, ‘hide_menu’);
?>
Remember this function can’t completely disable the theme options. It can be directly accessible by entering the url in address bar of a browser

0 comments: