With the new WooCommerce 4.1.0 just released, there's a new Marketing item in the menu. Looking at the URL, it goes to admin.php?page=wc-admin&path=/marketing
and by using the admin_menu
hook, I'm trying to remove this menu option.
I tried with the sub_menu
option and with remove_menu_page
option without success. If anyone can correct my code I would be very grateful.
add_action( 'admin_menu', 'remove_woocommerce_marketing_menu_option' );
function remove_woocommerce_marketing_menu_option(){
remove_menu_page( 'admin.php?page=wc-admin&path=/marketing' );
}
For WooCommerce <= v4.2
// Remove Marketing Hub menu item
add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );
For WooCommerce >= v4.3
WooCommerce 4.3 removed the woocommerce_marketing_menu_items
filter so the above snippet will no longer work. Thankfully, we can hook into another filter introduced in WooCommerce 4.0 as such:
add_filter( 'woocommerce_admin_features', function( $features ) {
/**
* Filter list of features and remove those not needed *
*/
return array_values(
array_filter( $features, function($feature) {
return $feature !== 'marketing';
} )
);
} );
Is the code working?
I have tested the above code snippet on WordPress version 5.5 and WooCommerce version 4.4 and it works as expected.
Coupons moved under Marketing in WooCommerce 4.4
In WooCommerce version 4.4, the Coupons feature was moved to the Marketing menu item as sub-item. There will still be a coupon menu item in the old location, and anyone stumbling upon it will be guided on the new location and asked to remove the legacy WooCommerce > Coupons
menu item.
However, if you are using the above code snippet, your Marketing
, and so, the Marketing > Coupons
menu items will be not available. In that case, your Coupons
menu item will reside in the old place as WooCommerce > Coupons
.
Credits: https://cinchws.com/remove-woocommerce-marketing-hub-menu-item/
add_filter('woocommerce_marketing_menu_items', 'woocommerce_marketing_menu_items');
function woocommerce_marketing_menu_items($marketing_pages){
return array();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With