如果URL已知,用户仍然可以创建新帖子,如
domain.com/wp-admin/post-new.php
这是你可以使用的代码。。。已将其添加到文件中functions.php
function hide_add_new() {
global $submenu;
// For Removing New Posts from Admin Menu
unset($submenu[\'post-new.php?post_type=post\'][10]);
// For Removing New Pages
unset($submenu[\'post-new.php?post_type=page\'][10]);
// For Removing CPTs
unset($submenu[\'post-new.php?post_type=custom_post_type\'][10]);
}
add_action(\'admin_menu\', \'hide_add_new\');
//Thanks to Howdy_McGee
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu(\'new-post\');
$wp_admin_bar->remove_menu(\'new-page\');
$wp_admin_bar->remove_menu(\'new-cpt\');
}
add_action( \'wp_before_admin_bar_render\', \'remove_admin_bar_links\' );
function disable_new_post() {
if ( get_current_screen()->post_type == \'my_post_type\' )
wp_die( "You ain\'t allowed to do that!" );
}
add_action( \'load-post-new.php\', \'disable_new_post\' );