So our website has about 20k "collaborators" type of users and we'd like to stop loading all of them on the select box on the "add new post" or "add new page" PAGE. Maybe load only authors and above type of users using functions.php

Could anybody help? =)

  • By default the author dropdown lists authors only. Make sure the collaborators don’t have the author role too, and no plugin is changing the arguments. – fuxia Aug 1 '12 at 10:09
  • I think, the dropbox list all users with rights of authors, also contributor and admins. – bueltge Aug 1 '12 at 11:05

This meta box is using the function wp_dropdown_users() to list all users. It has only one filter to change the output: wp_dropdown_users.

But this filter offers just the complete markup and users. It’s neither easy nor fast to parse this via regex for user names, check their roles and then give back an new HTML.

I think the best way is to deactivate this meta box.

remove_meta_box('authordiv', 'post', 'normal');

And then you create a custom meta box via plugin and list the authors of your blog only.

This small plugin does exactly that.

 * Plugin Name: Author Meta Box only with authors
 * Plugin URI:  http://wordpress.stackexchange.com/questions/60429/stop-loading-collaborators-users-on-add-new-post-or-page
 * Description: 
 * Author:      Frank Bültge
 * Author URI:  http://bueltge.de
 * License:     GPLv3
add_action( 'admin_menu', 'fb_remove_author_meta_boxes' );
function fb_remove_author_meta_boxes() {

    remove_meta_box('authordiv', 'post', 'normal');
    add_meta_box('fb_authordiv', __('Author'), 'fb_post_author_meta_box', 'post', 'normal', 'core');

function fb_post_author_meta_box( $post ) {
    global $user_ID;

    // get all authors
    $wp_user_search = new WP_User_Search( '', '', 'author' );
    $authors        = join( ', ', $wp_user_search->get_results() ); // user IDs
    <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
    wp_dropdown_users( array(
        'include' => $authors,
        'who' => 'authors',
        'name' => 'post_author_override',
        'selected' => empty($post->ID) ? $user_ID : $post->post_author,
        'include_selected' => true
    ) );

Gist 3225957 for Download

| improve this answer | |
  • thanks heaps mate. You save a lot of loading from my server + my time + my staff time! I really appreciate! – Dan Cortazio Aug 4 '12 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.