Skip to content

Instantly share code, notes, and snippets.

@robertdall
Last active December 11, 2015 18:58
Show Gist options
  • Save robertdall/4645418 to your computer and use it in GitHub Desktop.
Save robertdall/4645418 to your computer and use it in GitHub Desktop.
Hides Yoast SEO Plugin Field Columns for Author users and below
// Hides Yoast SEO Plugin Field Columns for Author users and below
// @since Jan, 2013
// @author R. Dall
if( current_user_can( 'edit_users' ) ) {
// The user can see all columns
}
else {
// The user has the SEO Columns hidden
function my_columns_filter( $columns ) {
unset($columns['wpseo-score']);
unset($columns['wpseo-title']);
unset($columns['wpseo-metadesc']);
unset($columns['wpseo-focuskw']);
return $columns;
}
// Filter pages
add_filter( 'manage_edit-page_columns', 'my_columns_filter',10, 1 );
// Filter Posts
add_filter( 'manage_edit-post_columns', 'my_columns_filter',10, 1 );
// Custom Post Type
add_filter( 'manage_edit-surgeon_columns', 'my_columns_filter',10, 1 );
}
@weskoop
Copy link

weskoop commented Jan 27, 2013

See my fork, you don't want to check current_user_can() every time the page loads, only when the filter is called. The empty if block is unnecessary, and unset can take as many variables as you feed it, not just 1 at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment