我正在尝试使用户角色的自定义帖子类型不可见subscriber
. 我该怎么做?
我尝试了以下方法,但似乎不起作用。我的帖子类型为request
.
$role = get_role( \'subscriber );
$role->remove_cap( \'read\' );
$role->remove_cap( \'read_request\' );
$role->remove_cap( \'read_private_requests\' );
$role->remove_cap( \'edit_request\' );
$role->remove_cap( \'edit_requests\' );
$role->remove_cap( \'edit_others_requests\' );
$role->remove_cap( \'edit_published_requests\' );
$role->remove_cap( \'publish_requests\' );
$role->remove_cap( \'delete_others_requests\' );
$role->remove_cap( \'delete_private_requests\' );
$role->remove_cap( \'delete_published_requests\' );
我想这可能会满足我的要求,但事实并非如此。有什么想法吗?
这是我自定义帖子类型的一部分:
register_post_type( \'antrag\', array(
\'labels\' => array(
...
),
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'menu_position\' => 10,
// \'capability_type\' => \'post\',
\'has_archive\' => true,
\'menu_icon\' => \'dashicons-welcome-write-blog\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'comments\', \'excerpt\', \'custom-fields\', \'revisions\' ),
\'capability_type\' => array( \'request\', \'requests\' ),
\'map_meta_cap\' => true,
)
);