feat: custom capabilities for editor role

parent 40da7b58
<?php
// Allow editors to see access the Menus page under Appearance but hide other options
// Note that users who know the correct path to the hidden options can still access them
function lpp_user_editors_capabilities() {
$user = wp_get_current_user();
// Check if the current user is an Editor
if ( in_array( 'editor', (array) $user->roles ) ) {
// They're an editor, so grant the edit_theme_options capability if they don't have it
if ( ! current_user_can( 'edit_theme_options' ) ) {
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
}
// Hide the Themes page
remove_submenu_page( 'themes.php', 'themes.php' );
// Hide the Widgets page
remove_submenu_page( 'themes.php', 'widgets.php' );
// Hide the Customize page
remove_submenu_page( 'themes.php', 'customize.php' );
// Remove Customize from the Appearance submenu
global $submenu;
unset($submenu['themes.php'][6]);
}
}
add_action('admin_menu', 'lpp_user_editors_capabilities', 10);
?>
<?php
/*
Plugin Name: Lab Place Plugin
Description: This plugin adds custom functionalities to the lab.place website.
Version: 0.1
Author: Montera34
Author URI: https://montera34.com
License: GPLv3
Text Domain: lpp
Domain Path: /lang/
*/
// LOAD PLUGIN TEXT DOMAIN
// FOR STRING TRANSLATIONS
add_action( 'plugins_loaded', 'lpp_load_textdomain' );
function lpp_load_textdomain() {
load_plugin_textdomain( 'urp', false, plugin_basename( dirname( __FILE__ ) ) . '/lang/' );
}
///
// EXTENDED USER SYSTEM
///
include_once('inc/user-signup.php');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment