user13987138
user13987138

Reputation:

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.

Upvotes: 4

Views: 1324

Answers (2)

Alexander-47u
Alexander-47u

Reputation: 51

remove_menu_page( 'woocommerce-marketing' );

Upvotes: 5

7uc1f3r
7uc1f3r

Reputation: 29624

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/

Upvotes: 2

Related Questions