Skip to content

Instantly share code, notes, and snippets.

@FernandoSalinas33
Created July 31, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoSalinas33/42a6825c1f69c9a49f01d7f65db806fa to your computer and use it in GitHub Desktop.
Save FernandoSalinas33/42a6825c1f69c9a49f01d7f65db806fa to your computer and use it in GitHub Desktop.
Hide certain menu items based on role
function add_custom_menus(){
$user = wp_get_current_user();
if ( in_array( 'employer', (array) $user->roles ) ) {
//The user has the "author" role
echo '<style type="text/css">.woocommerce-MyAccount-navigation-link--downloads {display: none;}.woocommerce-Addresses .u-column2 {display: none;}</style>';
}elseif ( in_array( 'candidate', (array) $user->roles ) ) {
//The user has the "author" role
echo '<style type="text/css">.woocommerce-MyAccount-navigation-link--downloads {display: none;}.woocommerce-MyAccount-navigation-link--orders {display: none;}.woocommerce-MyAccount-navigation-link--edit-address {display: none;}</style>';
}
}
add_action('wp_head', 'add_custom_menus');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment