Recently WooCommerce has added a lot of improvements to the plugin which we really appriciate but at the same time a lot of bloated features has alos been added to the plugin like Marketing Hub, a completely useless menu taking extra space among the other important menu items. Now if you find Marketing Hub to be useful, you can keep it.
But just in case you are looking for a way to remove these features that you no longer need from your WordPress Admin menus, take a look at the following code snippets. Please note: though I will show you how you can remove the Marketing Hub from your WP Admin menu list completely and make sure WooCommerce doesn't execute codes for that feature you don't need, you can do the same for other WooCommerce features as well like Analytics.
If you are using WooCommerce <= v4.2, you can simple add this one line of code in your theme's functions.php
file or make a simple feature plugin and use that to disable the Marketing Hub feature.
add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );
In WooCommerce v4.3, Marketing Hub has become a part of WooCommerce admin core features. So, the filter woocommerce_marketing_menu_items
no longer exists in WooCommerce v4.3 and hence the above code won't work. But at the same time as Marketing Hub has become a part of WooCommerce admin core features, you can disable it easily along with other WooCommerce features that you might not need for your website.
Here is the code snippet to remove Marketing Hub from WooCommerce in v4.3+.
// Remove WooCommerce Marketing Hub Menu from the sidebar - for WooCommerce v4.3+
add_filter( 'woocommerce_admin_features', function( $features ) {
/**
* Filter the list of features and get rid of the features not needed.
*
* array_values() are being used to ensure that the filtered array returned by array_filter()
* does not preserve the keys of initial $features array. As key preservation is a default feature
* of array_filter().
*/
return array_values(
array_filter( $features, function($feature) {
return $feature !== 'marketing';
} )
);
} );
Also just in case you need if you do var_dump($features)
to see the list of WooCommerce Admin features, you will get an array like this:
array(10) {
[0]=> string(15) "activity-panels"
[1]=> string(9) "analytics"
[2]=> string(19) "analytics-dashboard"
[3]=> string(32) "analytics-dashboard/customizable"
[4]=> string(9) "marketing"
[5]=> string(10) "onboarding"
[6]=> string(21) "shipping-label-banner"
[7]=> string(12) "store-alerts"
[8]=> string(5) "wcpay"
[9]=> string(10) "homescreen"
}
So, looking at this, you can easily disable more features along with Marketing Hub. For example if you want to disable Analytics along with ** Marketing Hub**, you can just simply tweak the above code like this:
// Remove WooCommerce Marketing Hub & Analytics Menu from the sidebar - for WooCommerce v4.3+
add_filter( 'woocommerce_admin_features', function( $features ) {
/**
* Filter the list of features and get rid of the features not needed.
*
* array_values() are being used to ensure that the filtered array returned by array_filter()
* does not preserve the keys of initial $features array. As key preservation is a default feature
* of array_filter().
*/
return array_values(
array_filter( $features, function($feature) {
return ! in_array( $feature, [ 'marketing', 'analytics', 'analytics-dashboard', 'analytics-dashboard/customizable' ] );
} )
);
} );
Hope this helps. 🙂
Seems this isnt working anymore. Looks like they go out of their way to advertise now.