Skip Navigation

[Resolved] Query filter using checkboxes field

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user is trying to filter his view by some checkbox value but it's not filtering correctly.
Solution:

If you're experiencing this issue, please try the fix below.
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 8.56 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 17 replies, has 2 voices.

Last updated by Zach Jones 6 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#626692

I've tried this with several different users (old and new) and it still isn't working for any of them. Please let me know if you need any other information to help solve this problem.

Thanks.

#626721

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Zach,

Thank you for trying this.

I've already escalated this ticket to our 2nd tier supporters for further debugging and will report anything that they find.

Thanks,
Shane

#627365

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Zach,

Thank you for the patience.

So the issue here is that its related to this errata page here :
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

If you're still having troubles you can then try the following hook and let me know if it helps.

add_filter( 'wpv_filter_user_post_query', 'prefix_modify_empty_user_query', 10, 4 );
function prefix_modify_empty_user_query( $items, $query_args, $view_settings, $view_id ) {
    foreach ($items as $key=>$item){
        $state_affiliation= get_user_meta($item->ID,'wpcf-state-affiliations', false) ;
        if(!isset($state_affiliation[0]['wpcf-fields-checkboxes-option-8f56cccf555d2d0573946e0232b5ae38-1'])){
            unset($items[$key]);
            continue;
        }
        if($state_affiliation[0]['wpcf-fields-checkboxes-option-8f56cccf555d2d0573946e0232b5ae38-1'][0]!='AK'){
            unset($items[$key]);
            continue;
        }
    }
    $items=array_values($items);

    return $items;
}

Thanks,
Shane

#627838

Thanks so much! Everything is working as it should now.