Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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

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
Something went wrong with that request. Please try again.