Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Searching by custom posts not restricted by user
This topic contains 4 replies, has 2 voices, and was last updated by Stephenburke 7 years, 4 months ago.
- AuthorPosts
- December 5, 2016 at 7:10 pm #11131
Hi guys,
The search bar won’t filter by registered courses for that user.
An example of a user who had no courses setup against them is brendankearns, password cbe71755$$ but they can search for all custom posts.
Regards,
Steve.December 6, 2016 at 10:38 am #11154Hi Steve,
I’ve looked up the LMS plugin code, and I have found a possible solution. I’ve made a minor modification to the initial custom code, for future reference it is now:
add_filter( 'asp_results', 'asp_filter_posts_by_capability', 1, 1 ); function asp_filter_posts_by_capability( $results ) { foreach ($results as $k => &$r ) { if ( !sfwd_lms_has_access($r->id) ) unset($results[$k]); } return $results; }
I have found that the “sfwd_lms_has_access” function should always return if the user has access to the particular object (lesson, topic, quiz etc..). So I changed the code according to that.
From my initial tests this appears to be working, but of course let me know if you find anything.
I’ve also increased the results limit to 25 from the initial 10, because in cases where the results pool is greater than the limit and none of the courses are accessible to the user from that pool, he might not get any results at all, because the results are removed after the search, during the post process.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 6, 2016 at 10:44 am #11155Wow,
This is brilliant. Thanks.
Great plugin, great support.
December 6, 2016 at 10:46 am #11156You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 6, 2016 at 10:56 am #11157Done, Thanks Ernest.
- AuthorPosts
The topic ‘Searching by custom posts not restricted by user’ is closed to new replies.