<?php
$n = 1;
$user_ID = get_current_user_id();
$count_posts = count(get_posts(array('author'=>$user_ID)));
if ($count_posts >= $n && isset(get_userdata($user_ID)->roles[0]) && get_userdata($user_ID)->roles[0]==='author'){
function remove_menu_items() {
remove_submenu_page( 'edit.php', 'post-new.php' );
}
add_action( 'admin_menu', 'remove_menu_items' );
function disable_create_newpost() {
global $wp_post_types;
$wp_post_types['post']->cap->create_posts = 'do_not_allow';
//$wp_post_types['page']->cap->create_posts = 'do_not_allow';
//$wp_post_types['my-post-type']->cap->create_posts = 'do_not_allow';
}
add_action('init','disable_create_newpost');
}
?>