Assign Multiple Custom User Roles to a Custom Post Type

Okay here's the situation.... I'm working on a my business website. There will be a work/portfolio area. "Work" is a custom post type. "Designer" is a custom user role. "Client" is a custom user role.

In creating a new "Work" post I would like to be able to select both a "designer" and "Client" to assign to the piece of work, as I would assign an author to a regular ol' post.

I tried the method from this answer but it did not work for me. ) I placed it in my functions.php file.

` add_filter('wp_dropdown_users', 'test'); function test($output) { 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;
}

`

Any help would be extremely appreciated!

Answers


This plugin may be what you're looking for http://wordpress.org/extend/plugins/members/

And this tutorial might also help, if you're not looking to use a plugin: http://shoutingwords.com/how-to-add-custom-user-roles-like-guest-author-to-your-wordpress-blog.html


Need Your Help

C++ SFML qt creator unresolved externals

c++ qt error-handling qt-creator sfml

I've been trying to set up qt creator with SFML for the past 2 weeks to no avail...

CodeIgniter PHP Model Access “Unable to locate the model you have specified”

php codeigniter model

I have been trying to load some models for this website I am building. However, for an unknown reason, it will bring the following error :

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.