Created
July 31, 2018 17:25
-
-
Save FernandoSalinas33/42a6825c1f69c9a49f01d7f65db806fa to your computer and use it in GitHub Desktop.
Hide certain menu items based on role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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