0
我想在编辑帖子页面的作者选择下拉列表中更改自定义帖子类型的用户列表。有没有我可以使用的过滤器钩子?我一直无法找到任何我想要的滤波器钩子上的信息。WordPress在编辑帖子中更改作者列表的过滤器作者框
挂钩应该(理论上)让我返回一个用户数组,这些将是填充底部选择框的用户。我想这样做的原因是我可以有条件地筛选出不同职位类型的用户。作为管理员(或其他管理员),我不想在将用户作为作者之前检查用户是否具有某种角色。的代码
实施例:
add_filter('example_filter', 'my_custom_function');
function my_custom_function ($users){
// Get users with role 'my_role' for post type 'my_post_type'
if('my_post_type' == get_post_type()){
$users = get_users(['role' => 'my_role']);
}
// Get users with role 'other_role' for post type 'other_post_type'
if('other_post_type' == get_post_type()){
$users = get_users(['role' => 'other_role']);
}
return $users;
}
我们可以看到你的代码吗? – surajsn
不知道为什么这个问题得到了downvoted ...更多的问题与一些更多的澄清和细节以及一些示例代码。我现在没有任何代码在我的主题中,但是因为我没有过滤器来连接。 –