wordpress中是否有任何钩子或技巧可以从后端隐藏wordpress注释选项卡中的注释通知红色警报?检查屏幕截图
这是作者的仪表板。
我还想从All、Pending、Approved等中删除并仅显示与作者帖子相关的数字。
wordpress中是否有任何钩子或技巧可以从后端隐藏wordpress注释选项卡中的注释通知红色警报?检查屏幕截图
这是作者的仪表板。
我还想从All、Pending、Approved等中删除并仅显示与作者帖子相关的数字。
您可以尝试使用此代码。完全删除backed中的注释功能。
将此代码放在当前主题函数中。php文件。
<?php
// Removes from admin menu
add_action( \'admin_menu\', \'my_remove_admin_menus\' );
function my_remove_admin_menus() {
remove_menu_page( \'edit-comments.php\' );
}
// Removes from post and pages
add_action(\'init\', \'remove_comment_support\', 100);
function remove_comment_support() {
remove_post_type_support( \'post\', \'comments\' );
remove_post_type_support( \'page\', \'comments\' );
}
// Removes from admin bar
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu(\'comments\');
}
add_action( \'wp_before_admin_bar_render\', \'mytheme_admin_bar_render\' );
?>
将此代码添加到函数中。php。它检查用户是否是管理员,或者是否可以调节其他用户的帖子。
Reference is here from WP Forum:
/* ------------------------------------------------------------
* Ensure that non-admins can see and manage only their own comments
*/ ------------------------------------------------------------
function myplugin_get_comment_list_by_user($clauses) {
if (is_admin()) {
global $user_ID, $wpdb;
$clauses[\'join\'] = ", wp_posts";
$clauses[\'where\'] .= " AND wp_posts.post_author = ".$user_ID." AND wp_comments.comment_post_ID = wp_posts.ID";
};
return $clauses;
};
// ensure that editors and admins can moderate everything
if(!current_user_can(\'edit_others_posts\')) {
add_filter(\'comments_clauses\', \'myplugin_get_comment_list_by_user\');
}
然而,$wpdb是一个非常强大的工具,可以运行到您的数据库中。你可以使用下面的功能:它的工作方式与上面类似,检查用户是否可以编辑其他帖子或是管理员。否则它只返回他们的帖子。Reference: From wpbeginner 函数posts\\u for\\u current\\u author($query){global$pagenow; if( \'edit.php\' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( \'edit_others_posts\' ) ) {
global $user_ID;
$query->set(\'author\', $user_ID );
}
return $query;
}
add_filter(\'pre_get_posts\', \'posts_for_current_author\');
以下代码(来自here, 中间部分删掉)允许我将登陆WP admin中某个页面的用户重定向到另一个管理页面。。。 function admin_redirects() { global $pagenow; /* Redirect Customizer to Theme options */ if($pagenow == \'customize.php\'){ wp_redirect(admin_url(\'/admi