Restricting number of posts in a category for members (membership plugin)

How can I restrict the number of posts that are made by a member?

I have the section set up where I allow them to post to a certain category, but I'd like to be able to restrict the number of posts made in the category, depending on the membership level.

For example, restrict members who sign up to add events (which has its own level) to 10, but restrict those who sign up to add holiday accommodation (a seperate level) to add just 1.

  • James Farmer
    • CEO (of WPMU DEV, honest)

    Hi WP3,

    Phew, that's a pretty full on restriction :slight_smile:

    The membership plugin is largely about access to stuff - this would be editing their fundamental WP privs (i.e. can post but only limited number).

    Something I'm sure that could be achieved - but could be pretty tricky... are there any other DEV users looking for this kind of edit? If there's enough interest we could give it a crack but otherwise you might be better off developing it yourself.

    Barry might have other ideas too though.

    Sorry for the delay on getting back to you on this one.

    Cheers, James

  • Moonworks
    • Code Wrangler

    No problem on the delay, I had a delay myself noticing a reply :o)

    The reason for these restrictions is that I am creating a community website for Somerset (by far the best County in England) and am tryign to set it up so people can sign up to different sections, each having its own membership. This would mean that if people wanted to add events, they can sign up to the events membership, or they could sign up to the Jobs membership to add vacancies, etc.

  • Barry
    • DEV MAN’s Mascot

    It's tricky and depends on how you implement it as there are a few ways.

    It would need a new admin rule (probably based on the blog_creation or group_creation rules but on the admin side). The simplest method would be to pull the users capability to create posts / pages when they reach the level.

    Unfortunately (i haven't checked yet) if there isn't a filter on capabilities and you have to use $user->remove_cap, then there isn't an easy way of adding the capability back if you increase the limit in the membership level, or move the user to a new level as WP doesn't have a simple "return users without this capability" query. Instead you'd need to cycle through all users, check their level, check for the rule and what the limit is, check how many posts/pages they'd already created and then reset the capability if needed.

    Pretty resource intensive.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.