When you delete a user in the WordPress admin, WordPress shows a dropdown to reassign that user’s content to another account. On small sites, this works fine. On a membership site with hundreds or thousands of members, it can grind to a halt. The dropdown tries to load every user in the database, and the page becomes slow or unresponsive.
This code recipe limits that dropdown to administrators only. The page loads quickly, and content stays assigned to accounts that are meant to manage it.
Do You Need This Recipe?
This recipe is worth adding if:
- Your membership site has a large user base, and the Users > All Users > Delete Users screen in the WordPress admin is slow to load or times out.
- You want to make sure that when a user is deleted, their content can only be reassigned to an administrator account, not to any member on the site.
If your user count is small and the dropdown loads without issue, you do not need this recipe. The default WordPress behavior works well at smaller scale.
About the Code Recipe
The recipe uses two WordPress hooks working together.
The first is load-users.php, which fires whenever the Users > All Users screen loads in the admin. Inside that callback, the code checks whether the current URL action is delete. We only want to modify the dropdown on the delete confirmation screen, not on every visit to the Users page.
If the action is delete, the code registers a filter on wp_dropdown_users_args. This filter intercepts the query that builds the user dropdown and sets the role parameter to administrator. WordPress then queries only administrator accounts when populating the list, instead of loading every user on the site.
The result is a focused dropdown that only shows admins. The deletion and content reassignment process itself is unchanged.
The Code Recipe
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
How to Customize This Recipe
Show a different role in the dropdown: Replace administrator in the $query_args['role'] on line 20 with any WordPress role slug. For example, use editor to restrict the user dropdown to editors.
You can also use a custom role’s slug if your site uses a dedicated membership manager role. You can find what roles exist by looking at the role filter at the top of the Users > All Users page.
Get Support From Our Team of Experts
For more help with this PMPro feature, check out our Support Page with three ways to get support as a free or premium member.


