Relevanssi_post_ok filter

Versions 2.9.8 (free) and 1.5.13 (premium) added a new filter, relevanssi_post_ok, which can be used to add support for membership plugins where there is a need to restrict certain posts from certain users.

By default, this filter calls relevanssi_default_post_ok(), which has built-in support for private posts, Role-Scoper and s2member. Add your own function, if you need more.

The filter passes two parameters: a boolean value (defaults to true) and the post ID. The filter wants the boolean value back. Make it true if the post can be shown and false if the user is not allowed to see the post.

How your function ends up with the response is up to you, but if you need to check the post status, I suggest you use relevanssi_get_post_status() instead of regular get_post_status(), as the Relevanssi function already has all post statuses cached. For post types, you can use relevanssi_get_post_type(). Both take post ID as an argument and return the obvious result.

  • Cindy Eberle

    love your plug in! What a difference it made! (Thank you!) Only one problem I don’t see addressed – My posts come up in searches, as I wish them to – but the FIRST result only does not link! Naturally, that is the most heavily weighted one, and important. Please advise?

    • Cindy, that sounds very much like a problem with your search results template.

      • Cindy Eberle

        Thank you. I was wondering about that. I will have to contact my theme author if I cannot find it. Appreciate your fast response.