0
사용자 그룹 "사용자"의 사용자가 "사용자 가이드 유형"작성을 허용합니다. 회원 플러그인을 다운로드하고 edit_guides, delete_guide 권한을 부여했습니다. 내 Function.php는 현재 :기능 태그를 변경 한 후 사용자 지정 게시 유형이 사라졌습니다.
add_action('init', 'cptui_register_my_cpt_guides');
function cptui_register_my_cpt_guides() {
register_post_type('guides', array(
'label' => 'Guides',
'description' => 'League of Legends Player Guides',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'guides',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'guides', 'with_front' => true),
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),
'labels' => array (
'name' => 'Guides',
'singular_name' => 'guides',
'menu_name' => 'Guides',
'add_new' => 'Add guides',
'add_new_item' => 'Add New guides',
'edit' => 'Edit',
'edit_item' => 'Edit guides',
'new_item' => 'New guides',
'view' => 'View guides',
'view_item' => 'View guides',
'search_items' => 'Search Guides',
'not_found' => 'No Guides Found',
'not_found_in_trash' => 'No Guides Found in Trash',
'parent' => 'Parent guides',
)
)); }
및
add_filter('map_meta_cap', 'my_map_meta_cap', 10, 4);
function my_map_meta_cap($caps, $cap, $user_id, $args) {
/* If editing, deleting, or reading a guides, get the post and post type object. */
if ('edit_guides' == $cap || 'delete_guides' == $cap || 'read_guides' == $cap) {
$post = get_post($args[0]);
$post_type = get_post_type_object($post->post_type);
/* Set an empty array for the caps. */
$caps = array();
}
/* If editing a guides, assign the required capability. */
if ('edit_guides' == $cap) {
if ($user_id == $post->post_author)
$caps[] = $post_type->cap->edit_posts;
else
$caps[] = $post_type->cap->edit_others_posts;
}
/* If deleting a guides, assign the required capability. */
elseif ('delete_guides' == $cap) {
if ($user_id == $post->post_author)
$caps[] = $post_type->cap->delete_posts;
else
$caps[] = $post_type->cap->delete_others_posts;
}
/* If reading a private guides, assign the required capability. */
elseif ('read_guides' == $cap) {
if ('private' != $post->post_status)
$caps[] = 'read';
elseif ($user_id == $post->post_author)
$caps[] = 'read';
else
$caps[] = $post_type->cap->read_private_posts;
}
/* Return the capabilities required by the user. */
return $caps;
}
모든 작품 내 능력 유형 = 포스트 경우. 그러나 내가 그것을 바꿀 때마다 가이드는 wp-admin에서 사라집니다. 미리 감사드립니다.