Skip Navigation

[Resolved] Control how many posts a member can make

This thread is resolved. Here is a description of the problem and solution.

Problem:
I want to limit the amount of posts a certain user can submit with cred.
How can I do this?

Solution:
It's not possible.
A possible Custom Approach (at your own risk and debug) is here:
https://toolset.com/forums/topic/control-how-many-posts-a-member-can-make/#post-485893

This support ticket is created 7 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by andrewB-7 7 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#485762

Hi there.

I have created a new custom post type using types, with custom fields.

I need each member to only be allowed to submit one instance of that post type.

They should be able to edit that post type (using cred forms on the front end). This part is working fine.

However they should not be able to create a second post in that same post type.

This is because their membership fee allows them to create only one such post.

Can you help me to make this happen, please?

Thank you very much again for your time.

Best wishes,
Andrew

#485893

It's not possible with Toolset unless you use some Custom Code.

The simplest approach is to create a Custom ShortCode that counts the posts of that type of this user, and depending on that, you display conditionally the CRED Form (or link to it).

Example:

/**
 *Count posts of given type, so each user can create post only once
 */
function u_post_count() {
    $user_post_count = count( get_posts( array( 
    'post_type' => 'your_post_type', 
    'author'    => get_current_user_id(), 
) ) );
        
    return $user_post_count;
}

It will count all Posts of the current logged in user.
Make sure to define the Post type in 'post_type'
It returns a numeric count.

This function can then be registered in Toolset > Settings > Front End Content > Functions inside conditional evaluations

After, it can be used on a HTML conditional to display or not the CRED form or the Link to it.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#486367

Oh wow. This sounds excellent thank you. I'll give that a try and let you know.

#486529

Please let me know if you need more info in regard 🙂

#486576

I will thanks.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.