WordPress.org

Support

Support » How-To and Troubleshooting » Limit # of total draft posts from each user?

Limit # of total draft posts from each user?

  • 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.

    Thanks!

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘Limit # of total draft posts from each user?’ is closed to new replies.