Created
April 19, 2024 15:04
-
-
Save raftaar1191/03cc1f202e3fb330f492318ccd5824e5 to your computer and use it in GitHub Desktop.
Only show the admin user list when deleting a user and assing his content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delete_user_account( $query_args ) { | |
// Use this array to specify multiple roles to show in dropdown | |
$query_args['role__in'] = array( 'administrator' ); | |
// Unset the 'who' as this defaults to the 'author' role | |
unset( $query_args['who'] ); | |
return $query_args; | |
} | |
add_filter( 'wp_dropdown_users_args', 'delete_user_account' ); | |
Notes: | |
Add a condition so that it only run on the wp-admin/users.php?action=delete&user=#$%#$%#$%$#%#%#%# page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment