I am using Relevanssi on a site which is also using User Access Manager. I wanted Relevanssi to show links to protected pages in the search results, but to show a please log in message instead of the excerpt. I created this custom excerpt function and added it to the theme's functions.php file. I use this function in my search.php template:
function custom_relevanssi_the_excerpt() {
global $post;
global $userAccessManager;
if (isset($userAccessManager)) {
$postId = $post->ID;
$uamAccessHandler = $userAccessManager->getAccessHandler();
$boolean = $uamAccessHandler->checkObjectAccess('post', $postId);
} else {
$boolean = true;
}
if (post_password_required($post)) {
echo __('There is no excerpt because this is a protected post.');
} elseif ($boolean) {
echo "<p>" . $post->post_excerpt . "</p>";
} else {
echo __('<p>This content is in the member area. Please <a href="/member-login/">log in</a> to see it.</p>');
}
}