Exclude Roles from new WP_Roles()
-
Hello, is it possible to exclude roles from new WP_Roles()? Basically I built a dropdown of user roles which works great; however, I need to exclude certain roles such as Administrator and Editor. I haven’t found any examples of this or much documentation at all. Maybe there’s a better way of achieving this I haven’t found?
<select class="author-search-select" name="staff_type" onchange="filterdata.submit();"> <option value="all">Show All</option> <?php $roles = new WP_Roles(); $roles_names = $roles->get_names(); foreach ( $roles_names as $role_slug => $role_name ) { // Check if the staff type is selected in the URL if ( $role_slug == $selected_staff_type ) { $set_select_staff_type = ' selected="selected"'; } else { $set_select_staff_type = NULL; } ?> <option value="<?php echo $role_slug; ?>"<?php echo $set_select_staff_type; ?>><?php echo $role_name; ?></option> <?php } ?> </select>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Exclude Roles from new WP_Roles()’ is closed to new replies.