Skip to content

Instantly share code, notes, and snippets.

@robgolbeck
Last active August 29, 2015 14:19
Show Gist options
  • Save robgolbeck/e345ca23d8e6de727051 to your computer and use it in GitHub Desktop.
Save robgolbeck/e345ca23d8e6de727051 to your computer and use it in GitHub Desktop.
WordPress Custom User Role
<?php
// Assign custom permissions for specific user roles
// This example gives Editors access to Menus and Theme Options:
add_action( 'admin_menu', 'edit_admin_menus' );
// Allow editors to manage theme options (under Appearance)
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
// Now hide all options except Menus & Customise
function hide_menu() {
remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
}
add_action('admin_head', 'hide_menu');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment