Ecommerce Shopify WordPress Discussion

Remove plugin menu pages for certain users

I have this code in WordPress custom plugin I'm writing: public function __construct() { add_action( 'admin_menu', array($this, 'hide_default_menu_pages') ); } public function hide_default_menu_pages() { $restricted_users = array( 'USERONE', 'USERTWO', ); // Getting the current user $current_user = wp_get_current_user(); // Getting the current user registered username $username = get_the_author_meta( 'nickname', $current_user->ID ); // Checking into the $restricted_users if the current logged user is blacklisted if( in_array( $username, $restricted_users ) ){ remove_menu_page( 'themes.php' ); remove_menu_page( 'plugins.php' ); remove_menu_page( 'edit-comments.php' ); remove_menu_page( 'tools.php' ); remove_menu_page( 'options-general.php' ); remove_menu_page( 'edit.php' ); remove_menu_page( 'upload.php' ); remove_menu_page( 'wc-admin' ); } } I want to remove for some users the ability to see the woocommerce pages and elementor pages, but the remove_menu_page() function seems not working, I think this will occur because the plugin pages don't really have a slug like the core pages of wordpress but use a querystring like this admin.php?page=wc-admin and admin.php?page=elementor. How I can achive the desired result?
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.