好的,这就是情况....我正在我的商业网站上工作。将有一个工作/投资组合区域。 “工作”是一种自定义的帖子类型。 “Designer”是一个自定义用户角色。 “客户”是自定义用户角色。
在创建新的“工作”帖子时,我希望能够选择“设计师”和“客户”来分配作品,因为我会将作者分配到常规的“帖子”。 / p>
我尝试了这个answer的方法,但它对我不起作用。我把它放在我的functions.php文件中。
`add_filter('wp_dropdown_users','test'); 功能测试($输出) { 全球$ 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;
}
`
非常感谢任何帮助!
答案 0 :(得分:2)
此插件可能是您正在寻找的内容 http://wordpress.org/extend/plugins/members/
如果您不想使用插件,本教程也可能会有所帮助: http://shoutingwords.com/how-to-add-custom-user-roles-like-guest-author-to-your-wordpress-blog.html