Created
September 25, 2024 15:58
-
-
Save themightymo/2ca44c853fb4027505bc899e0df36178 to your computer and use it in GitHub Desktop.
Hide the WPMUDEV account screen from all users except "themightymo" and "toby"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hide The Mighty Mo!'s Google Analytics account info from the Beehive Pro plugin | |
function restrict_admin_page_access() { | |
// Get current user's info | |
$current_user = wp_get_current_user(); | |
// Get the URL to restrict | |
$restricted_url = 'admin.php?page=beehive-google-analytics#/account'; | |
// Get current URL | |
$current_url = $_SERVER['REQUEST_URI']; | |
// Check if the current URL matches the restricted URL | |
if (strpos($current_url, $restricted_url) !== false) { | |
// Allow access only for users with the specified usernames | |
if ($current_user->user_login !== 'themightymo' && $current_user->user_login !== 'toby') { | |
// Redirect to the dashboard or another page | |
wp_redirect(admin_url()); | |
exit; | |
} | |
} | |
} | |
add_action('admin_init', 'restrict_admin_page_access'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment