Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created December 17, 2024 17:32
Show Gist options
  • Save nathaningram/21b5ccbe245793c5691fe91a8e575d31 to your computer and use it in GitHub Desktop.
Save nathaningram/21b5ccbe245793c5691fe91a8e575d31 to your computer and use it in GitHub Desktop.
Editor User Admin Cleanup
// Remove Tools and Kadence Menus for Editors
function ni_remove_tools_kadence_for_editors() {
if (current_user_can('editor') && !current_user_can('administrator')) {
// Remove 'Tools' Menu (default WordPress)
remove_menu_page('tools.php');
// Remove 'Kadence' Menu (from Kadence Blocks)
remove_menu_page('kadence-blocks');
}
}
add_action('admin_menu', 'ni_remove_tools_kadence_for_editors', 11);
// Add wpseo_manage_options Capability to Editors
function ni_add_wpseo_manage_options_to_editors() {
$role = get_role('editor');
if ($role && !$role->has_cap('wpseo_manage_options')) {
$role->add_cap('wpseo_manage_options');
}
}
add_action('admin_init', 'ni_add_wpseo_manage_options_to_editors');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment