0

i want author can not see some category from author admin panel but administrator can see that.how i can hide some category?my site http://techjagot.com ..

here show some function.php code

<?php

// Theme Settings Page
require_once(TEMPLATEPATH . "/theme-settings.php");

// Theme Styles
require_once(TEMPLATEPATH . "/theme-styles.php");

// Theme Widgets
require_once(TEMPLATEPATH . "/theme-widgets.php");

// Load Custom Post Options for Write Post and Write Page
require_once(TEMPLATEPATH . "/theme-metaboxes.php");

// Load Theme Javascript
require_once(TEMPLATEPATH . "/theme-js.php");

// Theme Image Functions
require_once(TEMPLATEPATH . "/theme-images.php");

// Register widgetized areas
function theme_widgets_init() {
    register_sidebar(array (
        'name'=>'Sidebar-Wide - Top',
        'id'=>'widget-1',
        'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
        'after_widget' => '</div></div>',
        'before_title' => '<h3 class="widgettitle"><span>',
        'after_title' => '</span></h3>',
        ));
    register_sidebar(array (
        'name'=>'Sidebar-Wide - Bottom Left',
        'id'=>'widget-2',
        'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
        'after_widget' => '</div></div>',
        'before_title' => '<h3 class="widgettitle"><span>',
        'after_title' => '</span></h3>',
        ));
    register_sidebar(array (
        'name'=>'Sidebar-Wide - Bottom Right',
        'id'=>'widget-3',
        'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
        'after_widget' => '</div></div>',
        'before_title' => '<h3 class="widgettitle"><span>',
        'after_title' => '</span></h3>',
        ));
    register_sidebar(array (
        'name'=>'Sidebar-Narrow',
        'id'=>'widget-4',
        'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
        'after_widget' => '</div></div>',
        'before_title' => '<h3 class="widgettitle"><span>',
        'after_title' => '</span></h3>',
        ));
    register_sidebar(array (
        'name'=>'Footer Widget 1',
        'id'=>'widget-5',
        'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
        'after_widget' => '</div></div>',
        'before_title' => '<h3 class="widgettitle"><span>',
        'after_title' => '</span></h3>',
    ));
1

Try the restrict categories plugin. It lets you configure which categories are visible in the Wordpress admin, based on the user role or the individual user.

1

Here is a small snippet that will do the job. Found it here.

/*
 * Hide Specified Categories (by ID) from administrators
 */

add_action( 'admin_init', 'wpse_55202_do_terms_exclusion' );

function wpse_55202_do_terms_exclusion() {
    //Where is the string 'author' you need to replace it with your users' role
    if( current_user_can('author') )
        add_filter( 'list_terms_exclusions', 'wpse_55202_list_terms_exclusions', 10, 2 );
}

function wpse_55202_list_terms_exclusions($exclusions,$args) {
    // edit 3 with your category's ID
    return $exclusions . " AND ( t.term_id <> 3 ) ";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.