Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add_role_filter_to_posts_administration(){
- //execute only on the 'post' content type
- global $post_type;
- if($post_type == 'post'){
- $user_role = '';
- // Get all user roles
- $user_roles = array();
- foreach ( get_editable_roles() as $key => $values ) :
- $user_roles[ $key ] = $values['name'];
- endforeach;
- // Set a selected user role
- if ( ! empty( $_GET['user_role'] ) ) {
- $user_role = sanitize_text_field( $_GET['user_role'] );
- }
- ?><select name='user_role'>
- <option value=''><?php _e( 'All Roles', 'papasemarone' ); ?></option><?php
- foreach ( $user_roles as $key => $value ) :
- ?><option <?php selected( $user_role, $key ); ?> value='<?php echo $key; ?>'><?php echo $value; ?></option><?php
- endforeach;
- ?></select><?php
- }
- }
- add_action('restrict_manage_posts','add_role_filter_to_posts_administration');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement