• Hi, I’ve researched a little, installed a few plugins but, as of yet, have been unable to restrict ‘editors’ on the website I manage from editing the homepage. I want the editors to be able to do everything included in the role, asides from edit the homepage (I want to restrict them from doing this). I run a multisite with around 10 subsites (each subsite has an editor, I am the admin). I don’t want them to be able to edit the subsite homepage – is this possible to set up? Thanks in advance, Paddy

Viewing 2 replies - 1 through 2 (of 2 total)
  • Add the following to your theme functions.php file:

    function restrict_editor_from_homepage() {
        if (!is_admin()) {
            return;
        }
    
        // Ensure the function get_current_screen is defined
        if (!function_exists('get_current_screen')) {
            return;
        }
    
        $screen = get_current_screen();
        if ('page' === $screen->id && isset($_GET['post'])) {
            $post_id = $_GET['post'];
            $home_page_id = get_option('page_on_front');
    
            if ($post_id == $home_page_id) {
                $user = wp_get_current_user();
                if (in_array('editor', $user->roles)) {
                    wp_die('You do not have permission to edit the homepage.');
                }
            }
        }
    }
    
    add_action('current_screen', 'restrict_editor_from_homepage');

    This checks to see if the page is frontpage/homepage and checks users role for editor. If it matches, it will show a message “You do not have permission to edit the homepage.”

    Thread Starter patricktrolan

    (@patricktrolan)

    Thank you so much. This works perfectly. Does exactly what I want it to, cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Restrict Editor Access on ONLY Homepage’ is closed to new replies.