Last active
July 5, 2018 00:38
-
-
Save gareth-gillman/1e877824551d3a949ea6e58311db8885 to your computer and use it in GitHub Desktop.
Hide columns based on user role
This file contains hidden or 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 my_manage_columns( $columns ) { | |
$user = wp_get_current_user(); | |
if ( in_array( 'author', 'editor', (array) $user->roles ) ) { | |
unset($columns['column-name']); | |
return $columns; | |
} | |
} | |
function my_column_init() { | |
add_filter( 'manage_posts_columns' , 'my_manage_columns' ); | |
} | |
add_action( 'admin_init' , 'my_column_init' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment