Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ajax Search Pro Does Not Include posts which are filtered by Groups Plugin
This topic contains 2 replies, has 2 voices, and was last updated by GenusWeb 4 years, 6 months ago.
- AuthorPosts
- May 21, 2019 at 8:37 pm #22800
Hi,
I am using the Plugin Groups by Itthinx to filter who are able to see some of the posts. Using the plugin, I can filter posts which can be viewed by only a certain group of users that I have set. It works properly with WordPress’ default search. However, when using Ajax Search Pro, any filtered posts by Groups Plugin do not appear on the Ajax Search Pro search results. Please see attachment for a screenshot of the issue.
Attachments:
You must be logged in to view attached files.May 22, 2019 at 1:46 pm #22814Hi,
I recall someone having a similar issue with that plugin. We resolved it by suggesting a custom code to exclude the posts that users have no access to. In your case it looks different. I think your search configuration might be incorrect somewhere. If you choose the correct post types, it should return everything, including the ones restricted from the current user. Please check your search configuration. Once you got that, then try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
Best,add_filter('asp_results', 'asp_fix_groups_exclusions', 10, 1); function asp_fix_groups_exclusions($results) { // Group based exclusions if ( class_exists('Groups_Post_Access') ) { foreach ($results as $k => &$r) { if ( isset($r->post_type) && !Groups_Post_Access::user_can_read_post($r->id) ) unset($results[$k]); } } // Category based exclusions if ( class_exists('Groups_Restrict_Categories') ) { foreach ($results as $k => &$r) { if ( isset($r->post_type) && !Groups_Restrict_Categories::user_can_read($r->id) ) unset($results[$k]); } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 23, 2019 at 9:49 pm #22834Thanks! For some unknown reason, it works now.
- AuthorPosts
You must be logged in to reply to this topic.