Skip to content

Instantly share code, notes, and snippets.

@benklocek
Forked from bueltge/author-filter-meta-box.php
Last active March 7, 2017 08:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benklocek/8cae13427ed7760cb76c to your computer and use it in GitHub Desktop.
Save benklocek/8cae13427ed7760cb76c to your computer and use it in GitHub Desktop.
<?php
/**
* 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 Bueltge
* 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', __('Authors Only'), '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_Query(array(
'query_id' => 'wps_not_subscriber',
'fields' => 'ID',
'meta_query' => array(
array(
'key' => 'wp_capabilities',
'value' => 'subscriber',
'compare' => 'not like'
)
)
)
);
$authors = join( ', ', $wp_user_search->get_results() );
?>
<label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
<?php
wp_dropdown_users( array(
'include' => $authors,
//'who' => 'authors',
'name' => 'post_author_override',
'selected' => empty($post->ID) ? $user_ID : $post->post_author,
'include_selected' => true
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment