0

This is regardging to On multisite installation and setting limit to content creation by sub-site admins.

I want to set a limit for posts,pages or any custom post types for any sub-site admins. So that they could just create certain number of pages and not more than that. I don't know what filter could help to set limit in functions.php.

Could any one help me with that? So that I could achieve it?

Thanks!

1

Important Link:

  1. Posts Creation Limits

Dig into this plugin you easily get the code for limit posts/pages.

0
function post_published_limit() {
$max_posts = 3; // change this or set it as an option that you can retrieve.
$author = $post->post_author; // Post author ID.

$count = count_user_posts( $author, 'CUSTOMPOSTTYPE'); // get author post count


if ( $count > $max_posts ) {
    // count too high, let's set it to draft.

    $post = array(
    'post_status'   => 'draft'
);

    wp_update_post( $post );
}

} add_action( 'publish_CUSTOMPOSTTYPE', 'post_published_limit' );

Hope this is your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.