Skip to content

Instantly share code, notes, and snippets.

@gareth-gillman
Last active July 5, 2018 00:38
Show Gist options
  • Save gareth-gillman/1e877824551d3a949ea6e58311db8885 to your computer and use it in GitHub Desktop.
Save gareth-gillman/1e877824551d3a949ea6e58311db8885 to your computer and use it in GitHub Desktop.
Hide columns based on user role
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