私は、その人が5つ以上の投稿を投稿しようとし、特定の役割(s2member 1)にある場合に、Wordpressを強制終了する関数を作成しようとしています。カスタム投稿タイプを使用しています。
global $current_user; // get the current author
$userid = $current_user->ID;
$args = array(
'post_type' => 'listing',
'post_status' => 'publish',
'author' => $userid
);
$the_posts = get_posts ( $args ); // get the published posts for that author
$post_count = count($the_posts); // count the number of published posts for the author
$N = 5; // set number for max posts per user
if ($post_count > $N) {
if (current_user_is('s2member_level1')) {
wp_die( 'message' ); // if the number of posts is more than N, kill the current post attempt so the author can't post
}
}