Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created April 19, 2024 15:04
Show Gist options
  • Save raftaar1191/03cc1f202e3fb330f492318ccd5824e5 to your computer and use it in GitHub Desktop.
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
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