Hide WPCodebox menu item and page from other users.
Make it availble to all admins with email of @agencyemail or by username
Hide WPCodebox menu item and page from other users.
Make it availble to all admins with email of @agencyemail or by username
add_action("admin_init", "disable_access_to_wpcodebox"); | |
function disable_access_to_wpcodebox() | |
{ | |
if (is_user_logged_in()) { | |
$current_user = wp_get_current_user(); | |
$username = $current_user->user_login; | |
if ( | |
strpos($current_user->user_email, "@agencyemail") === false && | |
!in_array($username, ["Usernameexample1", "Usernameexample2"]) | |
) { | |
remove_menu_page("wpcodebox2"); | |
if (isset($_GET["page"]) && $_GET["page"] === "wpcodebox2") { | |
wp_die("You do not have permission to access this page."); | |
} | |
} | |
} | |
} |