<?php if( current_user_can('editor') || current_user_can('administrator') ) { ?> // Stuff here for administrators or editors <?php } ?> // If you want to check more than two roles, you can check if the roles of the current user is inside an array of roles, something like: $user = wp_get_current_user(); $allowed_roles = array('editor', 'administrator', 'author'); <?php if( array_intersect($allowed_roles, $user->roles ) ) { ?> // Stuff here for allowed roles <?php } ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter