Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hides Any WordPress admin menu link from non-admin users.
<?php
/*
Plugin Name: Filter Admin Menu
Plugin URI: https://marcwoodyard.com
Description: Hides Any WordPress admin menu link from non-admin users.
Version: 0.1
Author: Marc Woodyard
Author URI: https://marcwoodyard.com
*/
function filter_admin_menu()
{
if ( ! current_user_can( 'update_core' ) )
{
remove_menu_page( 'wpseo_dashboard' ); //Hides Yoast admin menu link.
remove_menu_page( 'edit.php' ); //Hides post admin menu link.
//Learn More: https://codex.wordpress.org/Function_Reference/remove_menu_page
}
}
add_action( 'admin_menu', 'filter_admin_menu', 999, 0);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment