Hello,
I have set a parametric filter in a view that lists numbers, where each number is the ID of an user.
I need now to replace displaying of those numbers by the "display_name" value of each user.
Is it possible to do this in PHP ? Or must I use JS here ?
Thank you.
Let me make sure I understand your question. This is a custom field filter, and this custom field contains values that represent User IDs. You are using this custom field to link Posts and Users somehow, and in your search filter you would like to show the User display name instead of the numeric ID that is saved in the custom field. Is that correct?
The only way I can think of to do this is to remove the custom field filter from your Filter Control editor area, and insert a custom filter with PHP. Somehow you must get all the possible custom field values as an array of numbers. Then you must loop over each value to construct HTML options in a custom select field, or HTML checkboxes. Use the WordPress get_userdata() method to determine the display name of each user, and set the labels and values of each option to use the name and ID:
https://codex.wordpress.org/Function_Reference/get_userdata
Then you can use the Views API hook wpv_filter_start_filter_form to insert your custom filter in a View's filter controls automatically:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_start_filter_form
Once you have the inputs in your filter area, you can begin using your custom filter controls to update the search results.
Thank you for your complete answer.
Please don't close this thread yet ; I need a little bit more time.
Thank you.
No problem, I will mark this thread as pending an update from you. The ticket will remain open for 30 days. No need to reply right now.