Re: Relevanssi version 2.9.7 and s2member version 110731
Posted: September 15th, 2011, 2:16 pm
Hi there. I'm posting a friendly update on this thread, because s2Member's option value for this behavior is now changed to an array() instead of a string, starting with s2Member v110912+. So this change WILL impact the code sample I gave you before on installations running s2Member v110912+.
Here is an updated code sample for you that covers both versions.
Please let me know if you have any questions/concerns.
Here is an updated code sample for you that covers both versions.
Please let me know if you have any questions/concerns.
- Code: Select all
<?php
$alt_view_protect = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"];
if (version_compare (WS_PLUGIN__S2MEMBER_VERSION, "110912", ">="))
$completely_hide_protected_search_results = (in_array ("all", $alt_view_protect) || in_array ("searches", $alt_view_protect)) ? true : false;
else /* Backward compatibility with versions of s2Member, prior to v110912. */
$completely_hide_protected_search_results = (strpos ($alt_view_protect, "all") !== false || strpos ($alt_view_protect, "searches") !== false) ? true : false;
if (is_permitted_by_s2member (123))
{
// Show title and excerpt, even full content if you like.
// The current User/Member has access to Post or Page ID: 123.
}
else if (!is_permitted_by_s2member (123) && $completely_hide_protected_search_results === false)
{
// Show title and excerpt. Alt View Protection is NOT enabled for search results. However, do NOT show full content body.
// The current User/Member has no access to this content, but Alt View Protection is NOT enabled for search results.
// So in this case, s2Member site owners would expect to see protected titles/excerpts in search results.
}
else /* Do NOT show the search result at all. */
{
// Hide this search result completely.
// The User does not have access to this content, and Alt View Protection IS enabled for search results.
}
?>