New answers tagged

0

Jevuska is answer is corrected below detail of code check user role current user and display content conditionally. if ( is_user_logged_in() ){ $current_user = wp_get_current_user(); $roles = $current_user->roles; $level = 0; foreach( $roles as $role ){ if( in_array( array( 'administrator', 'shop-manager', 'adoption-agency'), ...


1

Your problem is that current_user_can() takes a capability not a user role. So, to check for an administrator, for example, you might use: if ( current_user_can( 'manage_options' ) ) { ... } because ordinarily only admins can manage options. You'd have to tie your custom user roles to capabilities that correspond to their roles, which are defined for ...



Top 50 recent answers are included