Hi @,
You can do that using jj4t3_is_human filter. Add something like this to your custom plugin or your theme’s functions.php
function exclude_googlebot_from_logs( $human ) {
// If user agent not found.
if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
return $human;
}
// If user agent is a bot, set human flag to false.
if ( preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
return $human;
}
apply_filters( 'jj4t3_is_human', 'exclude_googlebot_from_logs' );
-
This reply was modified 7 years, 11 months ago by
Joel James.
-
This reply was modified 7 years, 11 months ago by
Joel James.
Thread Starter
kowluk
(@kowluk)
it seems to me that this code removes googlebot entries from logs. I want logs to contain them.
Oops. I misread your previous post. Ok, that’s simple. Use below function.
add_filter( 'jj4t3_is_human', '__return_true' );
-
This reply was modified 7 years, 11 months ago by
Joel James.
Thread Starter
kowluk
(@kowluk)
Unfortunately, it still does not work with me. Maybe I’m doing something wrong. Just in case, can you check the operation of this rule? In any case, thanks for the quick support
Thread Starter
kowluk
(@kowluk)
by changing user agent into opera through user agent switcher and via SC – download as googlebot
Oh man, sorry. I wrote the above code wrong. It should be add_filter. Not apply_filters. I have updated above comment.
So your code should be, add_filter( 'jj4t3_is_human', '__return_true' );
Thread Starter
kowluk
(@kowluk)
In my custom plugin I used only this code:
add_filter( 'jj4t3_is_human', '__return_true' );
and now it works perfectly. Thank you again for your help!