Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Created February 23, 2018 11:56
Show Gist options
  • Save kimcoleman/b53cc5dd9f7cd024d0f86db5e532b4dd to your computer and use it in GitHub Desktop.
Save kimcoleman/b53cc5dd9f7cd024d0f86db5e532b4dd to your computer and use it in GitHub Desktop.
Remove some links from the WooCommerce My Account sidebar navigation if user is level 4.
<?php
/**
* Remove some links from the WooCommerce My Account sidebar navigation if user is level 4.
*
* @param array $endpoints The array of items in the account menu.
*/
function remove_woocommerce_account_menu_items( $endpoints ) {
$level = pmpro_getMembershipLevelForUser();
if ( esc_attr( $level->ID ) === '4' ) {
unset( $endpoints['edit-account'] );
unset( $endpoints['orders'] );
unset( $endpoints['edit-address'] );
}
return $endpoints;
}
add_filter( 'woocommerce_account_menu_items', 'remove_woocommerce_account_menu_items' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment