Both of these methods remove and restrict access to the WooCommerce "Extensions" menu page in the admin, which is what I want. But which method is more ideal?
By removing it (option 1) or by overriding the filter that creates it (option 2)?
Both options seem to work fine.
Option 1:
add_action('admin_menu', 'fs_remove_admin_menu_links', 999);
function fs_remove_admin_menu_links(){
$user = wp_get_current_user();
if( $user && isset($user->user_email) && '[email protected]' == $user->user_email ) {
remove_submenu_page('woocommerce', 'wc-addons');
}
}
Option 2:
function fs_new_remove_admin_menu_links() {
$user = wp_get_current_user();
if( $user && isset($user->user_email) && '[email protected]' == $user->user_email ) {
return false;
}
return true;
}
add_filter( 'woocommerce_show_addons_page', 'fs_new_remove_admin_menu_links' );
The goal is just to prevent access to the page for a certain user.
It seems to be added via the WooCommerce plugin by a function that includes:
if ( apply_filters( 'woocommerce_show_addons_page', true ) ) {
add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 );
}