2012-09-07 88 views
1

好的,這裏的情況....我正在我的商業網站上工作。將有一個工作/投資組合領域。 「工作」是一種自定義帖子類型。 「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; 
} 

`

任何幫助將非常感激!

回答

相關問題