• Resolved jhtjards

    (@jhtjards)


    Hi,
    I would like to exclude any logged-in users from the search log.

    I know Relevanssi has a feature to exclude selected registered wordpress users by id or name from the search logs.

    However, this can get a bit tedious with a site that has a lot or often changing users.
    Is there a way to exclude all registered users programatically with a filter hook in my functions.php?

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

    (@msaari)

    Yes. The filter hook you’re looking for is relevanssi_ok_to_log. Combine that with is_user_logged_in().

    Thread Starter jhtjards

    (@jhtjards)

    Thanks Mikko!

    This is the snippet I put into my functions.php, in case anyone’s interested:

    //Dont log WP users in Relevanssi search log
    add_filter( 'relevanssi_ok_to_log', 'rlv_block_wp_users', 10, 5 );
    function rlv_block_wp_users( $ok, $query, $hits, $user_agent, $ip ) {
      if ( is_user_logged_in() ) {
        $ok = false;
      }
      return $ok;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude any WP user from search log’ is closed to new replies.