admin管理员组

文章数量:1026134

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!

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!

Share Improve this question asked May 20, 2013 at 13:11 NetizenNetizen 1791 gold badge4 silver badges18 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Important Link:

  1. Posts Creation Limits

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

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.

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!

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!

Share Improve this question asked May 20, 2013 at 13:11 NetizenNetizen 1791 gold badge4 silver badges18 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Important Link:

  1. Posts Creation Limits

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

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.

本文标签: Setting limit to posts or page creation