WordPress.org

Forums

Limit the number of posts a user can make (19 posts)

  1. Please Add Screenshots
    Member
    Posted 6 years ago #

    I'd like someone to make me (or point me in the direction of) a plugin that sets a maximum number of posts a user can post. That is, limit the number of posts a user/author can make.

    Ideally this would be able to be determined both individually and also integrated with Role Manager so that i could make up a new Group and assign that group a set number of posts.

    Also... it would ideally be that I could limit the number of posts per user for certain categories.

    Would anyone be interested in making this plugin for me/wordpress... I'll pay if needed.

  2. Samuel B
    moderator
    Posted 6 years ago #

  3. Please Add Screenshots
    Member
    Posted 6 years ago #

    Are you saying we aren't allowed to post job requests or just giving me another choice?

  4. modifiedcontent
    Member
    Posted 6 years ago #

    I'd like to know as well. Isn't there a setting for this somewhere?

    I'm using a slightly modified version of WordPress for a specific purpose that requires a limit of one post per user.

    That shouldn't be too hard, right? One line of PHP that turns off the user ability to post (not to edit) when the number of posts counts hit 1 (or whatever)!

    Which database fields should I focus on? Where would I have to edit the code? What would the PHP look like?

    I'm not a PHP coder, but which some pointers I should be able to put this together. :-)

  5. GetWebHost
    Member
    Posted 6 years ago #

    This is an old topic but I am also looking for something like this.

    Does anyone already have a solution for this?

  6. artunplugged
    Member
    Posted 6 years ago #

    Hi,

    Did anyone find a solution for this?

  7. CrazySerb
    Member
    Posted 6 years ago #

    I'll put my name down for this one too... curious if and when anyone comes up with this, as I've been looking for it forever now too.

  8. beernews
    Member
    Posted 6 years ago #

    Yes, we NEED this!! Maybe it is present in WordPress MU?

  9. clyk
    Member
    Posted 6 years ago #

    Add me to the list!

  10. levislibra
    Member
    Posted 5 years ago #

    Respuesta en castellano-latino:

    Para limitar la cantidad de post de todos los usuarios a, digamos N posts yo hice lo siguiente:

    Modifique el archivo post-new.php de esta forma:

    <?php
    /**
    * New Post Administration Panel.
    *
    * @package WordPress
    * @subpackage Administration
    */

    /** Load WordPress Administration Bootstrap */
    require_once('admin.php');
    $title = __('Add New Post');
    $parent_file = 'edit.php';
    $editing = true;
    wp_enqueue_script('autosave');
    wp_enqueue_script('post');
    if ( user_can_richedit() )
    wp_enqueue_script('editor');
    add_thickbox();
    wp_enqueue_script('media-upload');
    wp_enqueue_script('word-count');

    if ( ! current_user_can('edit_posts') ) {
    require_once ('./admin-header.php'); ?>
    <div class="wrap">
    <p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the edit_posts capability to your user, in order to be authorized to post.
    You can also e-mail the admin to ask for a promotion.
    When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?>
    </p>
    </div>
    <?php
    include('admin-footer.php');
    exit();
    }
    //limitar la cantidad a N posts
    $N = 20; max 20 posts por usuario
    $count_posts = count(get_posts(array('author'=>$user_ID)));// retorna la cantidad de post escritos por el usuario correspondiente a $user_ID
    if ($count_posts >= N){
    Header("Location: index.php");//redirecciona al dashboard, en donde deberia indicarle al usuario que no puede crear un nuevo post
    }
    //fin de la modificacion

    // Show post form.
    $post = get_default_post_to_edit();
    include('edit-form-advanced.php');

    include('admin-footer.php');
    ?>

    Para poder limitar los posts por cada usuario seria necesario cambiar el N del codigo anterior por un campo especifico que pertenezca a cada usuario...
    Estoy trabajando en ello...

  11. clyk
    Member
    Posted 5 years ago #

    hey, if anyone could translate this into english, that would be awesome!
    cheers!

  12. zackattack
    Member
    Posted 5 years ago #

    Im looking for the exact same thing.

    i want to make a new role using "Capability Manager" and then select the role and be able to chose how many max posts that role can have and also be able to auto default a category just for that role.

    so all "submiters" will be able to submit 1 post and it auto goes into 1 category and they can only edit that one post.

    i have been looking and need this bad!

  13. Rodeo Imagination
    Member
    Posted 5 years ago #

    @levislibra post translation:

    So you can limit the number of posts of all users, to let's say N posts, I did this:

    I edited the file post-new.php this way:

    <?php
    /**
    * New Post Administration Panel.
    *
    * @package WordPress
    * @subpackage Administration
    */
    
    /** Load WordPress Administration Bootstrap */
    require_once('admin.php');
    $title = __('Add New Post');
    $parent_file = 'edit.php';
    $editing = true;
    wp_enqueue_script('autosave');
    wp_enqueue_script('post');
    if ( user_can_richedit() )
    wp_enqueue_script('editor');
    add_thickbox();
    wp_enqueue_script('media-upload');
    wp_enqueue_script('word-count');
    
    if ( ! current_user_can('edit_posts') ) {
    require_once ('./admin-header.php'); ?>
    <div class="wrap">
    <p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the edit_posts capability to your user, in order to be authorized to post.
    You can also e-mail the admin to ask for a promotion.
    When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?>
    </p>
    </div>
    <?php
    include('admin-footer.php');
    exit();
    }
    //limit the quantity to N posts
    $N = 20; max 20 posts por usuario
    $count_posts = count(get_posts(array('author'=>$user_ID)));// returns the quantity of written posts by current user to $user_ID
    if ($count_posts >= N){
    Header("Location: index.php");//redirects to dashboard, where it should point the user that he cannot create a new post
    }
    //end of modification
    
    // Show post form.
    $post = get_default_post_to_edit();
    include('edit-form-advanced.php');
    
    include('admin-footer.php');
    ?>

    To limit different number of posts for each user, it would be needed to change the N in the above code to an specific field that would belong to each user...
    I am working on that...

  14. zackattack
    Member
    Posted 5 years ago #

    i just tried that and go syntax error

    Parse error: syntax error, unexpected T_LNUMBER in /home/content/g/i/r/girlsgoneweed/html/_sites/nextpotmodel/wp-admin/post-new.php on line 36

  15. zackattack
    Member
    Posted 5 years ago #

    and... it would be best if the "ADD NEW" link would go away once reached max posts allowed.

  16. levislibra
    Member
    Posted 5 years ago #

    line 36:
    $N = 20; max 20 posts por usuario
    remplace:
    $N = 20; //max 20 posts por usuario

  17. zackattack
    Member
    Posted 5 years ago #

    ok, so i just tried that and it does not work.

    when i click on "ADD NEW" it goes to the dashboard no matter what user role the user has. i put max post to 1. i want each author to be able to only post 1 post. and everything else stays the same.

    thanks...

  18. clyk
    Member
    Posted 5 years ago #

    @ShirouJune: thanks for the translation!
    would be a great plugin, wouldn't it?

  19. andrea82
    Member
    Posted 5 years ago #

    This should be not a plugin but something integrated in WP itself.
    0 would mean unlimited.
    Any other number for limiting posts per user.

    Anybody willing to write a plugin for the community???

Topic Closed

This topic has been closed to new replies.

About this Topic