Searchable user custom fields and bad advice from ask.discourse.org

Maybe this should be two topics, but it’s an example of trying to solve a particular problem with the AI, and I still want an answer. :slight_smile:

I am helping someone who wants a bunch of user custom fields to be searchable. I told them they’d need a plugin, but they don’t. You can check the “searchable” option in the user settings (just how long has this been true?):

I can even type a / and search for user custom fields and it searches incrementally!

The problem I’m trying to solve is that they want to be able to search by location and it appears that the only way to do that right now is to have a user custom field with a second copy of the address, which seems yucky.

So I asked ask.discourse.org:

https://ask.discourse.com/discourse-ai/ai-bot/shared-ai-conversations/FOFRYdsQy6B--c0W-X6K4A

The interesting thing is that I thought that what the AI has to say is true, but almost none of it is.

Searching for a location (if it’s in a custom field) can be done (with the custom field hack), but it seems to get that nuance in the user directory search?

" There is no built-in way to search user custom fields via the search bar." That’s what I thought! I even gave them a huge price to write a plugin that would do that and then I find out it already exists.

I too suggested the data explorer solution; another bad idea. (So I’m **just as stupid as the AI!?!?!)

Also, the AI seems to frequently try to solve problems for the whole world and not just discourse:

Can we tell it to assume that questions are about Discourse (I’ll try to remind it in my future prompts). Can we tell it to never, ever recommend writing an .hbs file?

Back to the problem of searching for addresses

I guess a simple solution would be a plugin that had a callback on user profile edits that wrote the location to a user custom field location. I think that having it show on the card would allow it to be searched and shown in the search and then use CSS to hide it or the actual location field from the user card/profile.

Aah, not that long. :slight_smile:

I think the perfect solution would be a change to core to get the inbuilt user fields to also be searchable. It is a bit of an oddity that custom ones have more functionality than the default ones.

Though the new config pages format might work well for their inclusion. Having the ability to show/hide/disable as well as optionally making them searchable, etc would be a nice improvement.

You should be able to pull this info out using the data explorer though? But I’m assuming this is for their user base to use rather than an admin report?

3 Likes