Last active
September 18, 2020 17:16
-
-
Save SalmanRavoof/8861188a6e25dd3c948ebeaba21c2e00 to your computer and use it in GitHub Desktop.
Removes all the widgets from the WordPress dashboard screen for all non-admin users.
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 to remove the dashboard widgets, but only for non-admin users | |
// if you want to remove the widgets for admin(s) too, remove the 'if' statement within the function | |
function remove_dashboard_widgets() { | |
if ( ! current_user_can( 'manage_options' ) ) { | |
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); | |
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); | |
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); | |
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); | |
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); | |
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); | |
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); | |
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); | |
} | |
} | |
// | |
add_action( 'wp_dashboard_setup', 'remove_dashboard_widgets' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment