Wp gravity forms and menu access for editor role
It is preferable to give ( even paying clients ) and editor role instead of an administrator role. This way you can be in control over theme settings and plugin installations / updates. But there are some things you can a allow your editor to control that do not fit in the role capabilities. Two things I often run into are:
- Editting the menu
- Editting form settings
With the next code you can allow editors to edit forms and menus.
/** * Gravity and menu access */ function pud_add_form_menu_capabilities() { if ( get_option( 'pud_add_gravity_menu_access' ) != 'completed' ) { $role = get_role( 'editor' ); $role->add_cap( 'gform_full_access' ); $role->add_cap( 'edit_theme_options' ); update_option( 'pud_add_gravity_menu_access', 'completed' ); } } add_action('init', 'pud_add_form_menu_capabilities'); function pud_hide_menu() { if (current_user_can('editor')) { remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu remove_submenu_page( 'themes.php', 'customize.php?return=%2Fwp-admin%2Ftools.php' ); // hide the customizer submenu remove_submenu_page( 'themes.php', 'customize.php?return=%2Fwp-admin%2Ftools.php&autofocus%5Bcontrol%5D=background_image' ); // hide the background submenu // these are theme-specific. Can have other names or simply not exist in your current theme. remove_submenu_page( 'themes.php', 'yiw_panel' ); remove_submenu_page( 'themes.php', 'custom-header' ); remove_submenu_page( 'themes.php', 'custom-background' ); } } add_action('admin_head', 'pud_hide_menu');