I recently attempted to delete an administrator user. Using the bulk editor, I selected "delete" and was presented with the option to assign their content to another user. However, the dropdown contains thousands of users (subscribers, customers, etc), making it difficult to get to the correct admin user I'd like to reassign the content to.
As a workaround, I edited users.php directly and added
'role' => 'administrator', to the wp_dropdown_users() array. This accomplished what I needed, but I'd like to permanently customize this dropdown the correct way (custom users.php page or a hook/filter that returns administrator users only, from functions.php or an upgrade-safe method).
The full code for that edit is this (line 271 as of WP 5.0.3):
<ul style="list-style:none;"> <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> <?php _e('Delete all content.'); ?></label></li> <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array( $current_user->ID ) ), 'show' => 'display_name_with_login', 'role' => 'administrator', ) ); ?></li> </ul>
After some hunting, I found some helpful articles on adding a users page or customizing the users dropdown (if you want to add that somewhere else), but I'm not confident that putting the two concepts together will overwrite the existing users.php dropdown (it may just add a different users page).
How would you suggest pulling this off (ie. filter the users dropdown on the assign content screen)?
Thanks in advance!