Hi! Maybe something like this (I have not actual tried the code, but something like this should be the solution):
<?php
// Do not log actions performed by users who can edit posts.
add_filter('simple_history/log/do_log', function ($do_log) {
$current_user = wp_get_current_user();
// Bail if no user found.
if (!$current_user) {
return $do_log;
}
// Do not log if user can edit posts.
if ($current_user->has_cap('edit_posts')) {
return false;
}
return $do_log;
}, 10, 5);
Hi, the code above didn’t work for me, but with the edit below it did.
add_filter('simple_history/log/do_log', function ($do_log) {
if ( !current_user_can('edit_posts') ) {
return false;
} else {
return $do_log;
}
return $do_log;
}, 10, 5);
My only concern is how much it can spend processing, I have a site of 30,000 users and would like to record only the administrators’ edit logs.
@eskapism can you tell if there is CPU impact on a site with so many users? thanks!
-
This reply was modified 2 years, 7 months ago by Eder Ribeiro.
I just tested, apparently no bugs or slowdowns when implementing the plugin along with the filter above.
thanks!
Good to hear you solved it and that you see no bugs or slowdowns 👍.