Is it possible to control the way we search users?

Hi Cwicly community,

Recently I’ve built a user directory on our project and we built a search filter to search user’s name with Cwicly’s frontend render query.

Current this search only works when we search the exact username, for example, I have a user called
‘Example’, I can only find this user by search ‘Example’. When I try to search with ‘Ex’ or 'Exam, nothing will return.

Is there a documentation or a way for us to change the search behavior so it can be more sensitive? Like any way we can manipulate it with PHP?

Hi @lukelee,

I haven’t done this yet, so this is just a thought of mine that may raise more questions…

I’ve tried to avoid direct user approach as this could cause security issues depending on what you display on your site, like username and email.

It might be an option to create an acf group for users so they can enter unimportant information there that will be displayed on your page.

But that’s just based on very vague knowledge as I haven’t scratched the security issue with all the user stuff yet.

Cheers

@T-low Yea so the way we build our user object is to avoid showing those personal information you mentioned, so we are good in terms of security issue.

Looking for a solution here to enhance the search filter input so it can search by case-sensitive.

Bumping this to see if anyone has any clever idea?

Wondering if you have tried Ivory Search at all: Ivory Search – WordPress Search Plugin – WordPress plugin | WordPress.org

Is this something can work with Cwicly search input filter? I only want to use everything inside Cwicly

It doesn’t use a filter but it can all be created and styled with Cwicly.

Please see this thread for details:

From reading your post again, I can see you are already using a filter with front-end rendering so this method would require a change of approach, so may not be the perfect fit in this case.

So if anyone come across this issue as I did, then here is my solution:

Create an ACF field for user meta, and write a function in PHP to fetch your user’s display name (or whatever you wish to use for the search) and put it in the user meta you created automatically, then use the Meta Query for the search filter, then the search input will work like a champ as it will search anything that contains in your keyword.

Hope this helps.