How to set rules for the lenght of the contributors posts

Discussion in 'WordPress' started by Javi Uffhofen, Jan 28, 2011.

  1. #1
    Hi,

    I want the posts of the contributors of my blog to have a minimum size. How can I let WordPress check this automatically? I mean, I don´t want the posts to be submitted for review if they don´t exceed the minimum length.

    Thank you.

    Javi
     
    Javi Uffhofen, Jan 28, 2011 IP
  2. dsimi

    dsimi Member

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Paste the below code into functions.php

    
    
    // Content Limit
    
        function content($num, $more_link_text = 'Find out More...') {  
    
        $theContent = get_the_content($more_link_text);  
    
        $output = preg_replace('/<img[^>]+./','', $theContent);  
    
        $limit = $num+1;  
    
        $content = explode(' ', $output, $limit);  
    
        array_pop($content);  
    
        $content = implode(" ",$content);  
    
        $content = strip_tags($content, '<p><a><address><a><abbr><acronym><b><big><blockquote><br><caption><cite><class><code><col><del><dd><div><dl><dt><em><font><h1><h2><h3><h4><h5><h6><hr><i><img><ins><kbd><li><ol><p><pre><q><s><span><strike><strong><sub><sup><table><tbody><td><tfoot><tr><tt><ul><var>');
    
          echo close_tags($content);
    
          echo "<p><a href='";
    
          the_permalink();
    
          echo "'>".$more_link_text."</a></p>";
    
    }
    
    
    Code (markup):
    edit the following code to index.php

    
    <?php content(50, __('Find out More...')); ?>
    
    Code (markup):
     
    dsimi, Jan 28, 2011 IP
  3. Javi Uffhofen

    Javi Uffhofen Active Member

    Messages:
    169
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Hi dsimi,

    thanks a lot but I´m not sure that´s what I was looking for. I want the posts of the writers of a blog to be longer than x words. If they are note longer than x then the writer shouldn´t be able to send it to revision.

    Greetings

    Javi
     
    Javi Uffhofen, Feb 1, 2011 IP
  4. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I like these kind of questions, so going to theorize on how it can be done.

    In the post edit screen there is a word count below the textarea of the post. I am thinking that count is stored somewhere.

    You would have to hook into the Publish action and check for two things, if the poster is a contributor and that the word count is above your limit. If it passes, then it gets sent through to the editor (basically a draft). If if fails, then you send a message to the top of the screen (there is a filter for that).

    You can pore thru the Codex to find all of the particulars. Or hire someone to actually do it.
     
    Dodger, Feb 2, 2011 IP