Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Display text from Array on Results (ACF Checkbox)
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 2 years, 6 months ago.
- AuthorPosts
- November 18, 2020 at 12:24 am #30311
Hi guys,
The search system works perfectly and I’ve had no problems until today when the client asked us to add text under the User Search results, specifically the text from a checkbox that was created in ACF in a repeater field.
Under Advanced Options, under the User Result Fields & URL, I was able to add in the {user_referred_by} custom field in the “Advanced description field for User results” – this works without issue.
Now we have a repeater, and we’re trying to get a result from that;
Repeater Field Name: chapter_membership_info
Sub Field: leadership_roles“leadership roles” is a Checkbox which has choices as follows:
president : President
vice_president : Vice PresidentIs there a way to display the checkbox results, from a repeater, inside the User search? Regular ACF fields show without a problem, but is there something we can do for a repeater field, and an array inside that repeater?
Thanks,
November 18, 2020 at 10:17 am #30313Hi,
In short, it is not possible. Repeaters are very flexible fields, and there is no way we can implement a generic working solution unfortunately.
However, it is worth trying to look for a possible programmatical solution for your exact case, but it is definitely not easy.The asp_results hook lets you access the results before printing. You could use the ACF repeater API within that context
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 18, 2020 at 4:20 pm #30317Hi Ernest,
Thanks so much for the response. I figured that would be the case that the array would have been too much – especially 2 levels deep.I can try the hook method and see how that goes.
Is there a way I can target the hook to only work with one specific search form rather than all forms?
I’ll do some digging and see what I can come up with. Thanks again for the help!
Conor
November 19, 2020 at 8:46 am #30323Sure, you can pass on up to 4 arguments to that hook, you can find them in the linked documentation.
For example:
add_filter( 'asp_results', 'asp_custom_link_results', 10, 4 ); function asp_custom_link_results( $results, $search_id, $is_ajax, $args ) { .....
The $search_id variable holds the ID of the search shortcode.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.