Skip to main contentSkip to footer

Relevanssi has a conflict with User Access Manager plugin. Both plugins attach to the same `the_posts` filter hook with the same priority, and if UAM runs after Relevanssi, it may cause some issues, like missing excerpts or even broken search results pages.

The solution seems simple, however: at least in the one case I’ve run into so far, things started working after I moved Relevanssi to a slightly later priority, so it runs after UAM. That’s easy to do, just add the following code to your theme functions.php:

add_filter('after_setup_theme', 'rlv_move_to_later_priority');
function rlv_move_to_later_priority($priority) {
	remove_filter('the_posts', 'relevanssi_query');
	add_filter('the_posts', 'relevanssi_query', 11);
}

Update 19.1.2021: This is no longer necessary, as Relevanssi runs on `posts_pre_query` hook now.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Showing only one recurring event
Some event calendar plugins do recurring events by creating many posts. That’s fine until those cloned posts fill up your…
Relevanssi and languages
Relevanssi is language-agnostic in itself. It does not know any language and doesn’t care about which language the site uses.…

Related Posts:

Comment Section:

5 Comments. Leave new

  • We are still having the same issue over UAM vs Relevanssi after we tried the above solution. Is there any other way to rectify this?

    Reply
    • That fix doesn’t even do anything anymore, Relevanssi is now already by default on priority 99.

      What kind of problems you are having with UAM and Relevanssi? I tried it now and everything seems to work without problems. Relevanssi doesn’t respect the UAM restrictions and will show the posts in search results (but of course you can’t see the actual post), but I’ll fix that in the next version.

      Reply
      • Hi Mikko,
        Thanks for your reply.
        Our issue is UAM posts are still displaying in the search result.
        for eg,
        this post (https://www.parkwaycancercentre.com/from-survivor-to-volunteer/) should only visible to the login user, but its displaying in search result (https://www.parkwaycancercentre.com/?s=FROM+SURVIVOR+TO+VOLUNTEER).
        Thanks

        Reply
        • Ok, that isn’t even supposed to work in the current version, the current version doesn’t have any UAM compatibility built in.

          This will be fixed in the next version, but meanwhile you can add this to your theme functions.php:

          add_filter( 'relevanssi_post_ok', 'rlv_uam_post_ok', 11, 2 );
          function rlv_uam_post_ok( $post_ok, $post_id ) {
          	// User Access Manager.
          	global $userAccessManager; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
          	if ( isset( $userAccessManager ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
          		$type    = relevanssi_get_post_type( $post_id );
          		$post_ok = $userAccessManager->getAccessHandler()->checkObjectAccess( $type, $post_id ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
          	}
          	return $post_ok;
          }

          This should fix the problem.

          Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed