Skip to content

Instantly share code, notes, and snippets.

@tjhole
Created June 30, 2014 10:51
Show Gist options
  • Save tjhole/85f6a86785fd0d2b13ac to your computer and use it in GitHub Desktop.
Save tjhole/85f6a86785fd0d2b13ac to your computer and use it in GitHub Desktop.
WORDPRESS: Google Analytics Bouncer
function lxb_google_analytic_dashboard_bouncer() {
//is the GAD plugin active in the first place?
if(is_plugin_active('google-analytics-dashboard/google-analytics-dashboard.php')) {
//get the current user
$current_user_id=get_current_user_id();
//are you a super admin? if so, great
//remove the nav menu item for GAD page
$one = 'options-general.php';
$two = 'google-analytics-dashboard/gad-admin-options.php';
remove_submenu_page( $one , $two);
//thwart any attempts to access the page directly
if(isset($_GET['page'])){
$p = $_GET['page'];
if ($p == 'google-analytics-dashboard/gad-admin-options.php'){
wp_die('Insufficient permissions');
}
}
}
}
add_action('admin_menu', 'lxb_google_analytic_dashboard_bouncer');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment