jcadima
6/21/2015 - 4:26 PM

Disable Page Editor - Non Paying Clients

Disable Page Editor - Non Paying Clients

<?php
//REF:  http://wordpress.stackexchange.com/questions/17367/hide-page-visual-editor-if-certain-template-is-selected
// disables ALL pages for  editing
function remove_editor_init() {
/* You can wrap this inside your existing logic for detecting the current page template, so you only
disable the editor for specific pages.   */
        remove_post_type_support('page', 'editor');
}

add_action('init', 'remove_editor_init');



//// the following will disable page editing only for a certain template name
function remove_editor_init() {
    // if post not set, just return 
    // fix when post not set, throws PHP's undefined index warning
    if (isset($_GET['post'])) {
        $post_id = $_GET['post'];
    } else if (isset($_POST['post_ID'])) {
        $post_id = $_POST['post_ID'];
    } else {
        return;
    }
    $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
    if ($template_file == 'page-your-template.php') {
        remove_post_type_support('page', 'editor');
    }
}

add_action('init', 'remove_editor_init');