Display text from Array on Results (ACF Checkbox)

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

 
Keymaster
1 year, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30311

    Participant

    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 President

    Is 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,

    #30313

    Hi,

    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 :)


    #30317

    Participant

    Hi 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

    #30323

    Sure, 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 :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.