9

There is many a WordPress plugin out there that enhances WordPress search but I have yet to find a plugin that will add user search.

Search Everything used to have the functionality but was removed when WP moved to version 2.8. I suspect this was due to the way WP changed how authors were stored.

The reason why I'm after user search is because all users on the WP site are staff members with their own profile. We have an author page that lists all staff by surname that is separated by 20 members per page. If you only know the first name of a member of staff then trying to find that member is very hard. I want to extend WP search so you can simply enter a name and the corresponding member shows up.

This site is an intranet so using an external search engine is out of the question.

Just want to be clear that I'm wanting to search for users not search for posts by author.

How can I get staff member search added?

2
  • How about extending the posts hook on is_search with a WP_User_Query?
    – kaiser
    Nov 2, 2011 at 14:24
  • I don't know the answer, but I do know that BuddyPress allows you to search for users, and BP users are just WP users with a bit of extra meta. So, a place to start might be to download the plugin and have a look through it's code.
    – Peter HvD
    Jul 19, 2018 at 9:58

2 Answers 2

5

You can't achieve this easily with WP's built-in search system. Even if you managed to build a complicated query that pulls data from the user table, it would be incredibly slow.

Search Unleashed had this functionality, but I'm not sure about compatibility with WP 3.2.

I used it in the past as inspiration to add better search functionality on my site. Basically it gathers data on content publishing hooks, which then gets indexed and stored somewhere for faster accessing, for example a custom db table, or in special files if you're using the Lucene search engine.

If you really want to go the WP way, see this question. You need to join $wpdb->users on post_author.

1

Solution is here: http://wordpress.org/support/topic/default-custom-fields?replies=6

A quote from one of the posters on that thread:

...just for searching for posts by a certain person, NOT a keyword + the author. In my usage I am using Kaf's plugin that i mentioned above and I have 3 radio buttons, so you can search by "author's real name", "author's username", or the default search "post content"...

3
  • This answer doesn't help at all. The solution given in the forum post simply adds extra data to a post about the author that published it. The code given helps searches for posts by author not searching for members of staff/users.
    – Scott
    Nov 2, 2011 at 13:31
  • But that's what it does... "...enter a name and the corresponding member shows up..."
    – Roger
    Nov 2, 2011 at 13:37
  • 1
    But only if that author has published anything. In my case all my staff members will never publish anything. If they don't publish then their details are never added to a post meta thus they never show up in search results.
    – Scott
    Nov 2, 2011 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.