你可以钓到get_terms_args
根据您的用户/角色进行有条件的筛选
沿着这些路线的东西
add_filter( \'get_terms_args\', \'restrict_cat\', 10, 2 );
function restrict_cat( $args, $taxonomies ){
// Don\'t run if we are not dealing with categories
if( \'category\' != $taxonomies[0] )
return $args;
// The check for the user we want to restrict
// you could use current_user_can( $capability ) or test for a specific role here
if( 1 == get_current_user_id() ){
$args[\'exclude\'] = array(
\'cat_id1\',
\'cat_id2\'
);
return $args;
}
return $args;
}
退房
https://developer.wordpress.org/reference/functions/get_terms/ 获取可用参数的列表。