How to hide user dashboard details in WordPress?

Viewed 678

I'm trying to hide details from the backend user (not admin) WordPress dashboard like Recently Published From our Blog WordPress Events and News Admin Colour Scheme Help Activity Screen Options

I haven't been able to locate the html (php/javascript?) for any of it but located some html for the colour scheme picker as follows:

<h2>Personal Options</h2>
<table class="form-table">
<tr class="user-admin-color-wrap">
<th scope="row">Admin Color Scheme</th>
<td>
<fieldset id="color-picker" class="scheme-list">
<legend class="screen-reader-text"><span>Admin Color Scheme</span>. 
</legend>
<input type="hidden" id="color-nonce" name="color-nonce" 
value="98ec68455d" /><div class="color-option selected">
<input name="admin_color" id="admin_color_fresh" type="radio" 
value="fresh" class="tog"  checked='checked' />
<input type="hidden" class="css_url" value="" />
<input type="hidden" class="icon_colors" value="{&quot;icons&quot;:  
{&quot;base&quot;:&quot;#a0a5aa&quot;, 
&quot;focus&quot;:&quot;#00a0d2&quot;,&quot;
current&quot;:&quot;#fff&quot;}}" />
<label for="admin_color_fresh">Default</label>
<table class="color-palette">
<tr>
<td style="background-color: #222">&nbsp;</td>
<td style="background-color: #333">&nbsp;</td>
<td style="background-color: #0073aa">&nbsp;</td>
<td style="background-color: #00a0d2">&nbsp;</td>
</tr>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_light" type="radio" 
value="light" class="tog"  />
<input type="hidden" class="css_url" value="https://adsler.co.uk/wp- 
admin/css/colors/light/colors.min.css" />
<input type="hidden" class="icon_colors" value="{&quot;icons&quot;:  
{&quot;base&quot;:&quot;#999&quot;,&quot;focus&quot;
:&quot;#ccc&quot;,&quot;current&quot;:&quot;#ccc&quot;}}" />
<label for="admin_color_light">Light</label>
<table class="color-palette">
<tr>
<td style="background-color: #e5e5e5">&nbsp;</td>

Tried css:

 #tab-panel-overview {visibility: hidden;} 

.help-tab-content active {visibility: hidden;} 

.form-table {visibility:hidden; display:none;} 


.user-admin-color-wrap {visibility: hidden; display: none;}

Also tried:

.scheme-list {visibility:hidden;} 

Nothing.enter image description hereenter image description here

2 Answers

You mean the admin dashboard widgets? You can hide them with following wordpress action.

function remove_dashboard_widgets() {
    global $wp_meta_boxes;

    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

}

add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );

Please add this through a plugin or add the code to your functions.php. This is tested and will work.See screenshot attached

function stackinnerflow_remove_dashboard_widgets() {
    global $wp_meta_boxes;

    // Remove At a glance
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    // Remove Activity
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
    // Remove News and Events
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
}

add_action('wp_dashboard_setup', 'stackinnerflow_remove_dashboard_widgets' );

// removes the `profile.php` admin color scheme options
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

// Remove thanks WP
add_action('admin_head', 'stackinnerflow_footer_remove');

function stackinnerflow_footer_remove() {
  echo '<style>
              #footer-thankyou,
              #footer-upgrade {
                  display:none;
              } 
        </style>';
}

// remove the Help Tab use

add_action('admin_head', 'stackinnerflow_remove_help_tabs');
function stackinnerflow_remove_help_tabs() {
    $screen = get_current_screen();
    $screen->remove_help_tabs();
}

//remove the Screen Options Tab
add_filter('screen_options_show_screen', '__return_false');

If your wrap all the code for users below the level of administrator capabilities any user as editor or lower will not see this apart from the administrators.

if (current_user_can('editor')) {}

If you want to loop over a number of other capabilities, check this question: https://wordpress.stackexchange.com/questions/131814/if-the-current-user-is-an-administrator-or-editor

enter image description here

Related