将多个自定义用户角色分配给自定义帖子类型
问题描述:
好的,这里的情况....我正在我的商业网站上工作。将有一个工作/投资组合领域。 “工作”是一种自定义帖子类型。 “Designer”是一个自定义用户角色。 “客户”是一个自定义用户角色。将多个自定义用户角色分配给自定义帖子类型
在创建一个新的“工作”帖子时,我希望能够选择一个“设计者”和“客户端”分配给该作品,因为我将作者分配到常规作品。
我试过从这个answer的方法,但它没有为我工作。 )我把它放在我的functions.php文件中。
`add_filter('wp_dropdown_users','test'); ($输出) { global $ post;
//Doing it only for the custom post type
if($post->post_type == 'work')
{
$users = get_users(array('role'=>'designer'));
//We're forming a new select with our values, you can add an option
//with value 1, and text as 'admin' if you want the admin to be listed as well,
//optionally you can use a simple string replace trick to insert your options,
//if you don't want to override the defaults
$output .= "<select id='post_author_override' name='post_author_override' class=''>";
foreach($users as $user)
{
$output .= "<option value='".$user->id."'>".$user->user_login."</option>";
}
$output .= "</select>";
}
return $output;
}
`
任何帮助将非常感激!
答
其实,我一直用支杆2这些帖子可让您将帖子,页面和用户彼此连接起来。感谢您的建议。 –