• Hi!

    I’ve got around 800 users in my WordPress installation (WordPress 6.2, PHP 7.4), some with the same first or last names, but different usernames. I can’t find some of them using the last names, whereas others properly appear. Let me give you an example:

    I’m doing a search on /wp-admin/users.php for Müller.

    • Rolf Müller: I properly get this result. The last name isn’t identical with the username.
    • Hans Müller: I don’t get this result. I can find him though when searching for his username.

    I’m not using a caching plugin, I flushed all transients, and deactivated all plugins and themes, but the error persists. I also checked the database entries, I can’t see any different patterns between these two users.

    Does anyone have an idea what else I could try?

    Thank you very much!

Viewing 1 replies (of 1 total)
  • One possible reason why you’re not able to find some users when searching by last name could be that the last name field in the user profile is not being properly indexed by the WordPress search system. By default, WordPress only indexes the username and display name fields in the user profile for searching, so if the last name field is not included in the search index, you won’t be able to find users by their last names. To fix this issue, you can try installing a plugin like Relevanssi, which is a search plugin for WordPress that can improve the search functionality on your site. Relevanssi allows you to configure which fields in the user profile should be indexed for searching, so you can include the last name field in the search index.

    Another possible solution is to modify the WordPress search query directly, by adding a custom filter function to the pre_user_query hook. This filter function can modify the SQL query used to search for users, allowing you to include additional fields like the last name in the search criteria.

    Overall, I would recommend trying out a plugin like Relevanssi first, as it’s a simpler solution that doesn’t require modifying any code. However, if you’re comfortable with coding, the custom filter approach may offer more flexibility and customization options. Huddle Hyvee

Viewing 1 replies (of 1 total)
  • The topic ‘Backend: User directory doesn’t return all users’ is closed to new replies.