Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1660
    Microsmith
    Participant

    Hiya,

    How do i limit access to the Text tab next to the Visual Tab in post and pages? or how do i prevent users from inputting their own basic html codes to change text attributes?

    #1661
    Microsmith
    Participant

    Also need to know how to hide revisions from users

    #1662
    Vladimir
    Keymaster

    Hi,

    This code removes all HTML tags from the post content before save it for all users with ‘author’ role:

    add_filter('content_save_pre', 'nohtml_in_posts');

    function nohtml_in_posts($content) {
    if (current_user_can('author')) {
    $content = wp_filter_nohtml_kses($content);
    }

    return $content;
    }

    Include it into active theme’s functions.php file.

    #1663
    Vladimir
    Keymaster

    Code below removes all metaboxes from the post editor page for all users with “editor” role. Modify it for your own needs. Revisions metabox is ‘revisionsdiv’.


    add_action('add_meta_boxes', 'remove_post_metaboxes', 11);

    function remove_post_metaboxes() {
    if (!current_user_can('editor')) {
    return;
    }

    $side_metaboxes = array('formatdiv', 'categorydiv', 'tagsdiv-post_tag', 'postimagediv');
    $normal_metaboxes = array('revisionsdiv', 'postexcerpt', 'trackbacksdiv', 'postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv');

    foreach($side_metaboxes as $metabox) {
    remove_meta_box($metabox, 'post', 'side');
    }
    foreach($normal_metaboxes as $metabox) {
    remove_meta_box($metabox, 'post', 'normal');
    }

    }

    add_action('add_meta_boxes', 'remove_page_metaboxes', 11);

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.