如何从个人帖子的作者列表屏幕中删除管理员角色?要使用哪个挂钩来执行此操作?有人能帮我吗?
检查上述屏幕
这就是我上述问题的答案
add_action(\'pre_user_query\',\'ap_pre_user_query\');
function ap_pre_user_query($user_search) {
$user = wp_get_current_user();
if ($user->ID!=1) { // Is not administrator, remove administrator (you can add any user-ID)
global $wpdb;
global $user_ID;
//Fetch the custom field value added in user section
$meta = get_user_meta( $user_ID );
$selected_author_id = unserialize($meta[\'select_md\'][0]);
$count = count($selected_author_id);
//to the data you got add the current user to it
$selected_author_id[$count] = $user_ID;
$store_ids = \'\';
foreach($selected_author_id as $ids){
$store_ids .= $ids.\',\';
}
$final_ids = rtrim($store_ids,\',\');
//This query will return you the result you want
$user_search->query_where = str_replace(\'WHERE 1=1\',"WHERE 1=1 AND {$wpdb->users}.ID<>1 AND {$wpdb->users}.ID IN (".$final_ids.")",$user_search->query_where);
}
}
检查以下输出我是WordPress的新手,我正在尝试找出如何最好地设置权限。我想限制人员组只编辑某些页面(IT部门只编辑IT页面,人力资源部门只编辑人力资源页面等等)。据我所知,您取消了角色“编辑其他页面”的权限,然后将页面的作者设置为您要编辑的人。是否有一种设置多个作者的标准方法,或者是否有一种使角色成为作者而不是单个用户的方法?谢谢