您可以使用count_user_posts function.如果帖子被保存为WordPress帖子,则可以通过以下代码段完成:
if (is_user_logged_in()){
$userPostCount = count_user_posts(get_current_user_id());
if ($userPostCount > 1){
$user = new WP_User(get_current_user_id());
$user->add_cap(\'publish_posts\',false);
} else {
$user->add_cap(\'publish_posts\',true);
}
}