最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Setting limit to posts or page creation

matteradmin2PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far