User field searching / reporting

A number of our community users requested adding a custom user profile field for their Fediverse user names. That’s easy to add.

I experimented with making this field searchable. I found a post describing how this works, but my current version of discourse (up to date) does not present an interface like that. I do see results in the quick search field (labeled with value, that’s nice) and the expanded search shows matching users.

But… it is not picking up all matches. We have at least 3 more users (including me) that have a “mastodon” entered in this custom field. Is there some kind of delay on indexing?

Also, I was really looking for some way of running a search or a query to generate a list of all users who have entered some value in this field (e.g. show me all users with a fediverse user name). Is this a custom query job? How would I do that?

This could be done with the Data Explorer Plugin using an SQL query like:

SELECT ucf.user_id,
       ucf.updated_at AS reltime$time
FROM user_custom_fields ucf
WHERE = 'user_field_1'
AND ucf.value IS NOT NULL
ORDER BY ucf.updated_at DESC

Where 'user_field_1' would be custom user field on your site you’re looking to view. Note that Discourse uses user_field_1, user_field_2, user_field_3, etc, as the names for the custom user fields within the user_custom_fields table rather than the text name of the fields on the Customize → User Fields page.

If you wanted, you could get a list of all the names of the custom user fields on your site and their corresponding user_field number with:

FROM user_fields uf

Where the ID of the user_field would be the user_field_X name within the user_custom_fields table.

With that in mind, I’m not sure why you wouldn’t be able to search your user fields in the search window as long as the user field is searchable.

You might try using the advanced search menu and selecting “Users” as the place to search and see if you’re getting the same results:


Thanks Alex, the Data Explorer Plugin worked fantastic (my first time using it).

The search under User is not working at all. The values here are fediverse user names, and my entry is

but I get no results when I search Users for the string ‘mastodon’. Does it not do partial string matches? This is not terribly critical, and I will likely turn off the searchable flag for this field. I was hoping to provide a user accessible way to see all users who had entered a value for this field- is there an search option for the general earch that can find entries that are not empty?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.