Restricted posts are displayed in search (Memberships)

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Restricted posts are displayed in search (Memberships)

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 week, 2 days ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #40976

    Hey 🙂

    We want to include the amazing Search Plugin, but this time we have some posts with restricted content for some user roles.
    The posts are restricted but are displayed in the search box.
    How can we prevent this?

    We use the “Ultimate Membership Pro – WordPress Membership Plugin” (https://ultimatemembershippro.com/)
    (Their Documentation & Knowledge-base: https://help.wpindeed.com/ultimate-membership-pro/knowledge-base/)

    Do you have any idea or code snippet to optimize this?

    Thanks a lot
    Cheers
    Josh

    #40986
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Josh,

    Thank you very much for the details!

    I looked through the documentation but I could not find any functions reference or API. If you have access to their support, can you please ask them the following:

    Is there a way to programmatically check if the current user can access a specific post by ID?
    Something like user_can_access($post_id, $user_id) or anything similar.

    That is all I need 🙂

    Best,
    Ernest Marcinko

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


    #40989

    Hey Ernest,

    thanks a lot 🙂
    Their repsonse ist: At PHP side you may use this function to check if specific user has active a specific membership: function ihc_user_has_level($u_id, $l_id) There is no function for checking access to a post because a post may be restricted in many ways.

    Does it help?

    Cheers,
    Josh

    #40990
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you Josh.

    Well, that is rough. Can they suggest anything on how to check if a user/current user has access to a certain post?

    With that code I can only check if a user has a certain access level, but I need to check if the user has privileges to a certain post. Something like:

    1. Get the current user level IDs
    2. Get the access level IDs for the current post
    3. Compare and check

    I am only guessing as I don’t know their plugin, but there is certainly a way. For example when a user tries to access a post, which is restricted to them – we need to do the same check.

    Best,
    Ernest Marcinko

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


    #41030

    Hey Ernest,

    here is their reply:

    “There is not a simple check with a function but is crossing trough multiple classes (like CheckRestrictions) in order to establish if someone may access specific content or not. There is not a function that may be called from outside in order to have a such verification, unfortunately.”

    Sounds not really good, right?

    Cheers,
    Josh

    #41034
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That sounds really really bad. They are basically saying, that there is no way to check if a post should be visible for the current user.

    Best,
    Ernest Marcinko

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


    #41036

    But do you know why the “normal” WordPress Seach works fine accept the Ajax Search Plugin?

    #41039
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That means, there must be a hook applied for the regular search results then, we only need to apply the same exact thing and this would be resolved. Without them telling what that is I literally can’t do anything.

    If the regular search works, that means either there are query arguments applied or the results are moved during the post-process. Either way there is definitely a code we could apply for the live search too.

    Best,
    Ernest Marcinko

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


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.