Limit # of total draft posts from each user? (2 posts)

  1. GaryKing
    Posted 11 years ago #

    How can I create a limit that limits, say, 3 draft posts per user to be submitted to the blog?

    Or at least make it a bit tedious? Because I have a blog in which it allows users to register then submit articles for review, but I don't want it to be spammed to death as well.


  2. Kafkaesqui

    Posted 11 years ago #

    A hack-y way to do this... Open wp-admin/post.php in a text editor and around line 680 look for the section that begins:

    if (user_can_create_draft($user_ID)) {

    In this section, just after the $drafts = $wpdb->... query line, insert this:

    $num_drafts = count($drafts);
    if($num_drafts > 2 && $user_level < 9) {
    die("<p><strong>You're only allowed 3 post drafts at one time.</strong></p>");

    Not pretty, but it works. The $user_level check allows admins to access all drafts.

    With further editing (and a bit of PHP), you could work the $num_drafts value in to test whether to display the edit form or not, instead of just exiting out of the script process.

    Back up any source files before editing them, and comment changes so they are easy to locate in the future.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.