Last active
December 11, 2015 18:58
-
-
Save robertdall/4645418 to your computer and use it in GitHub Desktop.
Hides Yoast SEO Plugin Field Columns for Author users and below
This file contains 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
// 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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.