Forums › Forums › Search & Filter Pro › user specific results
- This topic has 13 replies, 2 voices, and was last updated 7 years, 1 month ago by Trevor.
-
Anonymous(Private) September 28, 2017 at 9:17 am #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(Private) September 28, 2017 at 9:43 am #133671In 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(Private) September 28, 2017 at 11:08 am #133697Thanks 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 ACFBest
P.Anonymous(Private) September 28, 2017 at 11:12 am #133700Perhaps I just could add a pameter to the query:
https://www.designsandcode.com/documentation/search-filter-pro/search-results/custom/Best
P.Anonymous(Private) September 28, 2017 at 1:55 pm #133727So 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(Private) September 28, 2017 at 3:58 pm #133788These 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.
Trevor(Private) September 29, 2017 at 7:09 pm #134020The settings all look OK. Yes, you can do that, see this 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/
-
AuthorPosts