Hide Theme options and Customize Admin menu

Direct answer: add_action( ‘admin_menu’, function() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition for the user means show menu for this user if(is_admin() && $user_name != ‘USERNAME’) { //We need this because the submenu’s link (key from the array too) will always be generated with the current SERVER_URI in mind. $customizer_url = … Read more

To remove default dashboard items and add quick draft widget for custom post type

You can remove the Screen Options with the ‘screen_options_show_screen’ filter. function myplugin_disable_screen_options( $show_screen ) { // Logic to allow admins to still access the menu if ( current_user_can( ‘manage_options’ ) ) { return $show_screen; } return false; } add_filter( ‘screen_options_show_screen’, ‘myplugin_disable_screen_options’ );

How to remove ‘create new post’ entry for a custom post type?

There are several ways (depending on what you’re trying to do): If it’s about the “publish” button You could… …remove the capability from the targeted role with remove_cap() …remove the publish button 1) 1) see bottom of the answer by @toscho …or the whole meta box 2) remove_meta_box( ‘submitdiv’, ‘custom_post_id’, ‘side’ ); 2) simplified version … Read more

How to change the label text in default setting pages?

You can modify the labels using gettext filter hook ex: add_filter( ‘gettext’, ‘theme_change_label_names’); function theme_change_label_names($translated_text){ if (is_admin()){ switch ( $translated_text ) { case ‘Site Title’ : $translated_text = __( ‘New Site Title label’, ‘theme_text_domain’ ); break; case ‘Tagline’ : $translated_text = __( ‘new Tagline label’, ‘theme_text_domain’ ); break; } } return $translated_text; }

Only allow administrators and editors to access wp-admin

You’re correct in that you should be checking for a capability. However, manage options is only given to administrators by default. You should check against a capability that both editors and administrators have such as delete_others_posts. function restrict_admin(){ //if not administrator, kill WordPress execution and provide a message if ( ! current_user_can( ‘delete_others_posts’ ) ) … Read more