12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Aug 9, 2021

How to remove Oxygen’s admin menu for all users other than a specific admin

Sridhar Katakam

Looking to remove Oxygen‘s top-level (incl. sub menu items) for everyone except a specific admin user?

Here’s the sample code for that:

add_action( 'admin_menu', 'wpdd_remove_menu' );
function wpdd_remove_menu() {
	// replace 1 with the admin user's ID that should see Oxygen's admin menu.
	$admin_that_should_see_oxygen_menu = current_user_can( 'manage_options' ) &&  1 === get_current_user_id();

	if ( ! $admin_that_should_see_oxygen_menu ) {
		remove_menu_page( 'ct_dashboard_page' );
	}
}

In the above, replace 1 with the ID of admin user that should see the Oxygen menu.

This can be added using a plugin like Code Snippets.

Show IDs can be used for quickly viewing the IDs of users (besides other items like posts).

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right