2012-09-17 3 views
1

저는 Wordpress에 대한 맞춤 분류에 대해서만 배우고 있습니다. 사용자가 택 소노 미를 사용할 수있는 액세스를 어떻게 제한 할 수 있습니까? 예를 들어 featured이라는 분류 체계를 만들었으며 편집자와 위의 역할 만이 분류에 게시물을 추가 할 수 있기를 바랍니다.맞춤 분류학 - 역할 또는 기능을 기반으로 액세스 설정

어떻게 액세스 수준을 설정합니까? 사용자 역할 또는 기능을 기반으로 둘 모두 나를 위해 작동합니다.

function add_custom_taxonomies() { 
    // Add new "Featured" taxonomy to Posts 
    register_taxonomy('featured', 'post', array(
     // Hierarchical taxonomy (like categories) 
     'hierarchical' => true, 
     // This array of options controls the labels displayed in the WordPress Admin UI 
     'labels' => array(
      'name' => _x('Featured', 'taxonomy general name'), 
      'singular_name' => _x('Featured', 'taxonomy singular name'), 
      'search_items' => __('Search Featured'), 
      'all_items' => __('All Featured'), 
      'parent_item' => __('Parent Featured'), 
      'parent_item_colon' => __('Parent Featured:'), 
      'edit_item' => __('Edit Featured'), 
      'update_item' => __('Update Featured'), 
      'add_new_item' => __('Add New Featured'), 
      'new_item_name' => __('New Featured Name'), 
      'menu_name' => __('Featured'), 
     ), 
     // Control the slugs used for this taxonomy 
     'rewrite' => array(
      'slug' => 'featured', // This controls the base slug that will display before each term 
      'with_front' => false, // Don't display the category base before "/locations/" 
      'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/" 
     ), 
    )); 
} 
add_action('init', 'add_custom_taxonomies', 0); 

답변

2

포스트 편집 페이지에서 METABOX을 제거하기에 충분 될 것이다 : 여기

내가 내 분류를 위해 사용하는 코드이다? 그래서, this에게 소용돌이를 제공하는 경우 :

function remove_featured_meta() { 
    if (!current_user_can('moderate_comments')){ 
     remove_meta_box('featureddiv', 'post', 'side'); 
    } 
} 

add_action('admin_menu' , 'remove_featured_meta'); 

당신은 appropriate capability 당신이 분류에 대한 액세스를 제한하고자 할 사용자 역할에 해당하는 중과 조건문을 입력 할 수 있습니다.

+0

흥미로운 접근법. 이 내용을 올바르게 이해하면 ** moderate_comments ** 할 수있는 모든 사용자가 게시물 편집에서 metabox를 볼 수 있습니까? –

+0

맞음! [WP 문서] (http://codex.wordpress.org/Roles_and_Capabilities)에서 볼 수 있듯이 편집자와 그 이상은 기본적으로 그렇게 할 수 있습니다. – crowjonah

+0

훌륭하고 훌륭한 답변입니다. 방금 마지막 질문 하나가 있는데, 왜 액세스 수준을 설정하는 핵심 기능이 없다는 것입니까? 나는 이것이 이상하지 않은 것으로 생각할 것이다. 그렇지 않습니까? –