Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    So, if you are talking about categories arhive pages results than please use following code snippe

    add_filter( 'aws_search_results_all', 'my_aws_search_results_all' );
    function my_aws_search_results_all( $result_array ) {
        $hidden_cats = array( '1', '2', '3' );
        if ( ! is_user_logged_in() && ! empty( $result_array['tax'] ) ) {
            foreach ( $result_array['tax'] as $tax_slug => $tax_arrs ) {
                foreach ( $tax_arrs as $tax_key => $tax_item ) {
                    if ( in_array( $tax_item['id'], $hidden_cats ) ) {
                        unset( $result_array['tax'][$tax_slug][$tax_key] );
                    }
                }
            }
        }
        return $result_array;
    }

    in this example categories with IDs 1, 2, 3 will be hidden for logged out users. You can edit this to add Ids of needed categories.

    Regards

    Thread Starter arohonka

    (@arohonka)

    Thanks again, it works.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide few categories from logged out’ is closed to new replies.