Disable Hide My WP Ghost for User Roles
January 3, 2023
Our plugin is designed to provide users with the highest level of security and customization. One unique feature of our plugin is the ability to whitelist specific IP addresses, which allows users to grant access to certain users while blocking others.
This can be particularly useful for businesses or organizations that want to grant access to employees or trusted partners while blocking access to unauthorized users.
If you want to disable the plugin for logged users with specific roles, you can add this code in the functions.php file of the theme:
add_action('template_redirect','hidePathsByUserRole'); function hidePathsByUserRole(){ if (function_exists('wp_get_current_user')) { $user = wp_get_current_user(); $allowed_roles = array( 'administrator', 'editor', 'author' ); if( isset($user->roles) && is_array($user->roles) && array_intersect($allowed_roles, $user->roles ) ) { add_filter('hmwp_process_paths', '__return_false'); add_filter('hmwp_process_buffer', '__return_false'); add_filter('hmwp_process_hide_disable', '__return_false'); add_filter('hmwp_process_find_replace', '__return_false'); } } }
The code will disable Hide My WP Ghost for administrators, editors and authors. You can add new roles or remove roles from the code.