Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable (remove) the marketing menu option in WooCommerce 4.3.x

Since the release of WooCommerce 4.3.x, the previous fix for removing the Marketing menu option that worked with 4.1.x does not work anymore and I'm wondering if anyone knows how to remove it for 4.3.x.

I've tried all of these without success:

#1:

add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );

#2:

add_action( 'admin_init', 'remove_wc_marketing_menu_item' );
    function remove_wc_marketing_menu_item() {
    remove_menu_page( 'admin.php?page=wc-admin&path=/marketing' );
}

#3:

add_action( 'admin_init', 'remove_wc_marketing_menu_item' );
    function remove_wc_marketing_menu_item() {
    remove_menu_page( 'wc-admin&path=/marketing' );
}

#4:

add_filter( 'woocommerce_marketing_menu_items', 'remove_wc_marketing_menu_item' );
    function remove_wc_marketing_menu_item( $marketing_pages ) {
    return array();
}

None of them work with the latest WP and WC. I have no other plugins installed and I'm not using a customized child theme or anything like that.

All ideas are welcome.


2 Answers

remove_menu_page( 'woocommerce-marketing' );

like image 160
Alexander-47u Avatar answered Sep 18 '25 16:09

Alexander-47u


The FeaturePlugin.php contains on line 292-301

/**
 * Overwrites the allowed features array using a local `feature-config.php` file.
 *
 * @param array $features Array of feature slugs.
 */
public function replace_supported_features( $features ) {
    $feature_config = apply_filters( 'woocommerce_admin_get_feature_config', wc_admin_get_feature_config() );
    $features       = array_keys( array_filter( $feature_config ) );
    return $features;
}

So you get: (Tested in WooCommerce 4.3.1 version)

function filter_woocommerce_admin_get_feature_config( $feature_config ) {   
    $feature_config['marketing'] = false;

    return $feature_config;
}
add_filter( 'woocommerce_admin_get_feature_config', 'filter_woocommerce_admin_get_feature_config', 10, 1 );

Source: https://gist.github.com/isaumya/89f48dcd84cb58af1e668bb76ba2c029 - https://github.com/woocommerce/woocommerce-admin/issues/4716

Available as a plugin: https://wordpress.org/plugins/disable-dashboard-for-woocommerce/

like image 25
7uc1f3r Avatar answered Sep 18 '25 16:09

7uc1f3r