当用户角色不是编辑或管理员时,如何消除管理面板中的“特色”类别(及其子树)?
避免在内容输入时向特定用户角色显示特定类别
1 个回复
SO网友:Rutwick Gangurde
它使用get_terms
和wp_get_object_terms
内部获取类别。您可以使用与这些函数关联的过滤器来实现所需的功能。
<?php
//$args = apply_filters( \'get_terms_args\', $args, $taxonomies );
add_filter(\'get_terms_args\', \'wpse53900_filter_cat\');
function wpse53900_filter_cat($args, $taxonomies){
//this is where you can check the taxonomies and roles to filter out the ones you want
//additionally, make sure to add a check here so that your code runs only on the post edit/add screens
}
应该给你一个主意!;)结束