Support » Plugin: Relevanssi - A Better Search » Using "relevanssi_post_ok" hook

  • Hey,

    I’m trying to get Relevanssi to work with WordPress Access Control plugin (here)
    At the moment member restricted posts/pages are showing up in the search results. Can I use the “relevanssi_post_ok” hook somehow to check if the post/page can be viewed by the current user? and if so how? sorry I’ve searched all over on how to use this hook and can’t find much.

    I’m trying to have posts that are only viewable to people logged in, then enable those post to be set so even non logged in user can see them later on. I’ve tried a number of access/role plugins but this one is the only one that seem stoo work with custom post types so I really need to get relevanssi working..

    help appreciated

    thanks

    http://wordpress.org/extend/plugins/relevanssi/

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes, relevanssi_post_ok is exactly what you need. Usually the best way to figure out how hooks work is a quick look to the source code where they are used.

    The hook fires in lib/search.php. It’s a filter hook, which is handed a boolean value (initially set to ‘true’) and the function needs to return ‘true’ if the current user is allowed to see the post and ‘false’ if not.

    The filter has one extra parameters, which has the post ID.

    By default, relevanssi_default_post_ok() is attached to the hook with the default priority of 10. That function can be found in lib/common.php – it’s probably a good idea to see what it does. It also has the basic functionality for Role-Scoper, which is a good sample (and the next function in the file is the s2member compatibility function, which can also help).

    If you do sort this out and your code is not too specific for your needs, you could post it here and I can add it to Relevanssi core eventually.

Viewing 1 replies (of 1 total)
  • The topic ‘Using "relevanssi_post_ok" hook’ is closed to new replies.