Skip to content

Instantly share code, notes, and snippets.

@Garconis
Last active February 4, 2021 21:20
Show Gist options
  • Save Garconis/2f9d8da3d83d911e38d795eee9b49c6d to your computer and use it in GitHub Desktop.
Save Garconis/2f9d8da3d83d911e38d795eee9b49c6d to your computer and use it in GitHub Desktop.
WordPress | Remove WP Activity Log plugin from Admin list and Admin sidebar
<?php
/**
* Check if WP Activity Log plugin is active
**/
function hide_wp_security_audit_log(){
if ( is_plugin_active( 'wp-security-audit-log/wp-security-audit-log.php' ) ) {
// hide it from the Plugin list
add_filter('all_plugins', 'fs_remove_wp_activity_log_admin_plugin_list');
function fs_remove_wp_activity_log_admin_plugin_list($plugins) {
// get current User
$user = wp_get_current_user();
// get their email address
$email = $user->user_email;
// check the email's domain
$domain = 'example.com';
// check if email address matches domain list
$banned = strpos($email, $domain) === false;
// if current user's email addess doesn't match domain list, then hide the menu items
if( $user && $banned ) {
unset($plugins['wp-security-audit-log/wp-security-audit-log.php']);
}
return $plugins;
}
// hide it from the Admin menu
add_action('admin_menu', 'fs_remove_wp_activity_log_admin_menu_links', 999);
function fs_remove_wp_activity_log_admin_menu_links() {
// get current User
$user = wp_get_current_user();
// get their email address
$email = $user->user_email;
// check the email's domain
$domain = 'example.com';
// check if email address matches domain list
$banned = strpos($email, $domain) === false;
// if current user's email addess doesn't match domain list, then hide the menu items
if( $user && $banned ) {
remove_menu_page('wsal-auditlog');
}
}
}
}
add_action('admin_init' , 'hide_wp_security_audit_log');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment