User field searching / reporting

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

SELECT ucf.user_id,
       ucf.value,
       ucf.updated_at AS reltime$time
FROM user_custom_fields ucf
WHERE ucf.name = '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:

SELECT uf.id, uf.name
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:

2 Likes