Forums Forums Search & Filter Pro user specific results

Viewing 10 posts - 1 through 10 (of 14 total)
  • Anonymous
    #133667

    Hello,

    I’m running a site where logged in users can only see posts which are assigned to a user specific category. How can I add this functionality to s&f ? Is there a hook to maniplate the results or can I expand the query, so that the user only get a result with assigend posts?

    Best
    P.

    Trevor
    #133671

    In general, Search & Filter would use the visibility settings of a post to determine what to include in search results. If a post has restricted viewing, then only those permitted to see it should be able to. That, of course, depends on the method used to restrict the post. It can get very complicated.

    If experimentation suggest that this is not working, it may be the way that the membership plugin you are using does it.

    Anonymous
    #133697

    Thanks for your answer. Howerver I’m not sure if that is exactly my point…
    I’ll try to descriobe in other words –

    I have WP Users with post catergories assigend to them (via ACF) .
    Can I manipulate the S&F results before or after the query in a way that a logged in user sees
    only the post which have categories that assigend to him?
    I use no membership plugin – just this ACF

    Best
    P.

    Anonymous
    #133700

    Perhaps I just could add a pameter to the query:
    https://www.designsandcode.com/documentation/search-filter-pro/search-results/custom/

    Best
    P.

    Anonymous
    #133727

    So I’ve tried :

    <?php echo do_shortcode('[searchandfilter id="17"]'); ?>
    
    <div id="main">
      
            <?php
    
                                    //get next event from now on
    
                                    $args = array (
      'post_type'              => array( 'title' ),
      'posts_per_page'         => '100',
      'order'                  => 'ASC',
      'orderby'                => 'menu_order',
      
    
    );
    
    $args['search_filter_id'] = 17;
    
                                    // The Query
                                    $query = new WP_Query( $args );
        
        
       
                                      
                                    // The Loop
                                    if ( $query->have_posts() ) {
                                        while ( $query->have_posts() ) {
                                            $query->the_post();
                                        
                                     
                                      
    
                                      $title = get_the_title();
                                     echo '<li>'.$title.'</li>';
    
                                  
    
                                     
    
                                  
                                      
    
                                        }
                                    } else {
                                        echo 'No results!.';
                                    }
    
                                    // Restore original Post Data
                                    wp_reset_postdata();
                                    
                                     ?>
    
     
    
    </div>

    and in backend I’ve set “Search in the follwing post types” to “title” and “Display Results” to “custom” . However I get a “No results!” as soon as i comment
    $args['search_filter_id'] = 17; out – I get the results as expected…

    Any ideas on this ? I hoped I could manipulate the query in custom mode as I want to – this seems
    to be the only reason why this mode exist, right?

    Best
    P.

    Trevor
    #133788

    These WP Users and the Categories assigned to them. Is this data held in the WP Users table? WP Users are a special type of post, in that the data is not held in the normal WP Posts table. Our plugin does not cache the Users table.

    It Does see the users assigned to posts as authors, but does not do anything other than a basic name lookup for search purposes. It cannot look at any other fields in that Users table.

    Anonymous
    #133794

    Hello Tevor,

    at this point I’m just trying to get a basic “custom result” page up an running.
    As you see in my code I’ve a custom post type “title” with standard wp categories assigned, but I get no result.

    Best
    P.

    Trevor
    #133810
    This reply has been marked as private.
    Anonymous
    #133942
    This reply has been marked as private.
    Trevor
    #134020

    The settings all look OK. Yes, you can do that, see this filter:

    Edit Query Arguments filter

    You will find examples of other users’ usage in this forum by searching for this:

    https://support.searchandfilter.com/forums/search/sf_edit_query_args/

Viewing 10 posts - 1 through 10 (of 14 total)