Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Only Include Admins in the WordPress User Delete Dropdown

Дата публикации: 25-06-2026 19:39:36

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 (more...)

Основное содержимое страницы с новостью.

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.

Featured image for Only Include Admins in the WordPress User Delete Dropdown

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.

This code recipe does not alter or remove any content; it only adjusts the available options when reassigning a deleted user’s posts.

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.

PMPro Team

Author: PMPro Team

The editorial staff at Paid Memberships Pro is a team of WordPress membership site and online business experts led by Kim and Jason Coleman. Trusted by over 350,000 readers worldwide.

View more articles by PMPro Team »

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.

Was this article helpful?

YesNo

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Troubleshooting Email Delivery on Your Membership Site0730-06-2026
2Allow Member to Opt-Out of New Series Notification Emails0703-07-2026
3Require User Fields on the Member Profile Edit Page0530-06-2026
4Send new user ‘…would like to join…’ emails to specific admin users07.5428-07-2026
5Exclude Billing Fields for Specific Membership Levels at Checkout0526-06-2026
6Looper not showing author?0112-07-2026
7Civil Engineering Notes started the topic Found an issue at buddypress/bp-members/classes/class-bp-members-admin.php in the forum How-to & Troubleshooting0523-04-2026
8How a 140 GB Community Archive Moved to PMPro Max With Zero Data Loss5729-06-2026
9Register a Custom Font Family for Memberlite0524-06-2026
10Memberlite 7.1: Block-Based Header & Footer Variations5703-07-2026

Классификация: Мнения. Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 7. Источник: www.paidmembershipspro.com.