This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10755
    IntegrityProvidersIntegrityProviders
    Participant

    I just purchased Ajax Search Pro and love how it works for the most part. I am struggling to find how to limit what is shown when a user does a search. Our WordPress site has pages that contain info that not all users are allowed to see. We will have many users and many different user roles as well.

    Can you let me know how I can stop a user from seeing pages/posts in the search results that they do not have permissions to see? Please note that if I click on the search result for a restricted page it does not show the details of that restricted page but it does show an image and some of the description text in the search results box and we do not want it to show the restricted pages/post at all.

    Please advise. Thanks.

    Jeremy

    #10765
    Ernest MarcinkoErnest 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.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Limit search results based on user permissions’ is closed to new replies.