Reply To: Limit search results based on user permissions

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Limit search results based on user permissions Reply To: Limit search results based on user permissions

#10765

Ernest Marcinko
Keymaster

Hi Jeremy,

It depends on how the restrictions are managed, as there is no such feature in core wordpress to restrict users from content based on roles (as far as I know). Are you using a specific plugin for this purpose or a custom code?

If the plugin/solution you are using has some kind of function or any other way of getting the restricted page IDs for the currently logged in user, then it's possible to solve it very simply.

The search API allows to add page/post ID exceptions via custom code as well. The solution would be to get the IDs for the current user, and append it to the search arguments, like so:

This filter allows to statically exclude page IDs, which are defined in the $ids variable. However if there is a way to get all the page IDs for the current user, then it could be assigned to the $ids variable and solve the problem.

If you know by any chance how to get the restricted IDs for the current user, I would suggest a modification to the upper mentioned filter.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)