阻止包括管理员在内的所有用户创建自定义帖子类型的新帖子

时间:2016-12-19 14:27:52

标签: wordpress custom-post-type

有没有简单的方法可以阻止包括管理员在内的所有用户阻止创建自定义帖子类型的新帖子。但是可以编辑。

低于我的尝试:

function is_edit_page($new_edit = null){
global $pagenow,$typenow;
//make sure we are on the backend
if (!is_admin()) return false;


if($new_edit == "new" && "reviews" == $typenow)
    wp_redirect( admin_url(), 302 );    
}
add_action( 'current_screen', 'is_edit_page', 10, 1 );

这不起作用。

我也试过

register_post_type( 'custom_post_type_name', array(
   'capability_type' => 'post',
   'capabilities' => array(
    'create_posts' => 'do_not_allow',
    ),
   'map_meta_cap' => true, 
));

它也不起作用

  

它不适用于其他用户。如shop_managers

0 个答案:

没有答案