如何在WordPress中隐藏用户仪表板详细信息?

时间:2019-06-16 18:38:54

标签: html css wordpress

我正在尝试向后端用户(而非管理员)WordPress仪表板隐藏详细信息,例如Recently Published From our Blog WordPress Events and News Admin Colour Scheme Help {{1} } Activity

我一直无法找到其中的html(php / javascript?),但是为配色方案选择器找到了一些html,如下所示:

Screen Options

尝试过CSS:

<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>

也尝试过:

 #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;}

一无所有。enter image description here enter image description here

2 个答案:

答案 0 :(得分:0)

您的意思是管理仪表板小部件? 您可以通过以下wordpress操作隐藏它们。

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

答案 1 :(得分:0)

请通过插件添加此代码,或将代码添加到您的functions.php中。 经过测试,可以正常工作。请参见所附的屏幕截图

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 (current_user_can('editor')) {}

如果您要遍历许多其他功能,请检查以下问题:https://wordpress.stackexchange.com/questions/131814/if-the-current-user-is-an-administrator-or-editor

enter image description here