You may want to select users as authors which you do not want to allow the direct editing or creating of posts.
function wp_author_users() { global $post; /* * User roles you want to be author of posts */ $roles = array( 'administrator', 'contributor' , 'subscriber' ); $users = array(); foreach($roles as $role) { $users = array_merge($users, get_users('role='.$role)); } $output = "<select id=\"post_author_override\" name=\"post_author_override\" class=\"\">"; /* * Leave the admin in the list */ $output .= "<option value=\"1\">Admin</option>"; foreach($users as $user) { $sel = ($post->post_author == $user->ID)?"selected='selected'":''; $output .= '<option value="'.$user->ID.'"'.$sel.'>'.$user->user_login.'</option>'; } $output .= "</select>"; return $output; } add_filter('wp_dropdown_users', 'wp_author_users'); |
Be First to Comment