• Resolved nyakuza

    (@nyakuza)


    I’m currently trying to find a good search plugin to use on my sites, and none of them offer out-of-the box compatibility with WP Members.

    So that has led me to writing some code for them to ensure that content restricted by WP Members does not show up in the search results for non-logged-in users. And equally, that if a user is logged in that they can see restricted pages in their search results.

    What I need to find out is what data or flag WP Members uses to mark a page/post as restricted. Would you be able to let me know what that would be and where I can find it? That way I can reference it in my code to tell those search plugins to include/exclude content marked as such for users based on if their login status.

    Many thanks for any advice you can offer.

    Also, if you know of any great search plugins that do offer out-of-the-box compatibility with WP Members I’d be interested in that too!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    Instead of marking posts as “restricted”, mark them as “hidden” – then they wouldn’t show up in search results or anywhere else, unless the user had access to them.

    • This reply was modified 1 month, 1 week ago by Chad Butler.
    Thread Starter nyakuza

    (@nyakuza)

    Hi,

    Thanks for that suggestion. Unfortunately that won’t work well for my site, as the content needs to remain visible even to users who are not logged in, so they know it exists and have the option to login to view it.

    Ideally I need to know what data WP Members adds to the database in order to mark a page/post as restricted. Would you be able to let me know what that data is named, and where I can find it? That way I can reference it in my code.

    Many thanks.

    Plugin Author Chad Butler

    (@cbutlerjr)

    While that could be found easily by looking at the source, it’s not a recommended approach. Looking at the actual data saved (post meta) would break if there were ever a change in the core plugin’s schema.

    The plugin has an API function wpmem_is_blocked() for determining if a given post is restricted or not. Used in the loop, it will check whatever the current post ID is. To check a specific post, pass $post_id as an argument. The function returns a true|false boolean.

    https://rocketgeek.com/plugins/wp-members/docs/api-functions/wpmem_is_blocked/

    Thread Starter nyakuza

    (@nyakuza)

    Thanks very much for that advice, that API function will be extremely useful.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.