Skip to content

Instantly share code, notes, and snippets.

@markjaquith
Last active October 22, 2023 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save markjaquith/8500474 to your computer and use it in GitHub Desktop.
Save markjaquith/8500474 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: SQMS Remove Menu Items
Plugin URI: http://sequoiaims.com
Description: Plugin for Sequoia MasterSite to remove menu items based on current user level
Author: Ryan Olson
Author URI: http://thatryan.com
Version: 1.1
*/
function remove_wordpress_seo_menu() {
global $proLevel; // This marks this variable as global, so it can be accessed elsewhere, in later code
require_once(WP_PLUGIN_DIR . '/pro-sites/pro-sites.php');
$psObj = new ProSites();
$proLevel = $psObj->get_level();
if( $proLevel == 1 || $proLevel == 2 || $proLevel == 3 ) {
remove_action( 'admin_menu', array( $GLOBALS['wpseo_admin'], 'register_settings_page' ), 5 );
}
}
add_action( 'init', 'remove_wordpress_seo_menu' );
function sqms_remove_menu_items(){
global $proLevel; // We do this so we can access the global variable created earlier
if( $proLevel == 1 || $proLevel == 2 || $proLevel == 3 ) {
remove_menu_page( 'edit.php?post_type=acf' );
}
if( $proLevel != 0 && $proLevel < 2 ) {
remove_menu_page( 'edit.php?post_type=testimonials-widget' );
remove_menu_page( 'edit.php?post_type=cctor_coupon' );
remove_menu_page( 'edit.php' );
}
}
add_action('admin_menu','sqms_remove_menu_items');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment