Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › restricting results
This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 10 months ago.
- AuthorPosts
- May 25, 2021 at 7:06 pm #33404
how can i restrict search results? your product is not complying with s2member restrictions.
thanks
R
May 25, 2021 at 7:10 pm #33405You cannot access this content.May 26, 2021 at 12:38 pm #33424Hi,
Does the s2member plugin has an api? That code looks all right to me, but I assume the current_user_can function does not work with the s2member plugin.
Best,
There is probably a different function to check if the current user can access the post by ID.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 26, 2021 at 2:22 pm #33429You cannot access this content.May 26, 2021 at 3:06 pm #33437Hi,
I understand that, but each plugin works differently. I am not the developer of S2Members plugin, I don’t know how it hooks into different functions of the WordPress core.
It is impossible for us to test our plugins against all of the major plugins out there, but of course everyone tries to make everything work together and making compatible.To make it work the first step is to get to the S2Members api to find an internal S2Member plugin function – and I am sure there is one – which we can substitute into the code you mentioned above. Then simply change that one line where the role check is executed:
!current_user_can(‘read_post’, $r->id)
I am more than happy to help with the integration for a 3rd party plugin, even though it is not part of our support duties. If you know of any developer documentation, API or knowledge base links for that plugin, please feel free to share with us.
The closest I could find is this one. However I don’t know if that works in the ajax context, but worth a try:
Best,add_filter( 'asp_results', 'asp_filter_posts_by_capability', 10, 1 ); function asp_filter_posts_by_capability( $results ) { foreach ($results as $k => &$r ) { if ( !is_permitted_by_s2member($r->id) ) unset($results[$k]); } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.