Discover in this tutorial how to improve the performance of websites with many users with a simple code snippet.
WordPress 6.0 introduced performance improvements for sites with many users. This improvement was already in WordPress multisite and was carried over to individual installations
That is, from this version (6.0 and higher) on sites with more than 10,000 users, WordPress uses new functions (get_user_count
, wp_update_user_counts
and wp_is_large_user_count
) to more efficiently manage the database query.
This is great, but you might want to modify that more or less arbitrary limit of 10,000 users to one that better suits your needs.
That is, if you have an installation of more than 5,000 users and you notice that the user page or edit entries page is slow, it is worth trying these improvements.
Let’s see how to achieve this using the new wp_is_large_user_count
filter.
Snippet that allows you to modify the threshold of users from which WordPress performance is improved
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
It’s that simple.
In this code you use the wp_is_large_user_count
filter to modify the threshold at which the performance improvements will be applied.
In this case, you set the limit to 5000 users but you can change this number to whatever suits you best.
Conclusion
Now you know how to modify the threshold to get performance improvements applied on WordPress sites with many users.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉