Skip Navigation

[Resolved] [GUIDE] Limiting amount of posts a user can create to 1 [RESOLVED]

This support ticket is created 2 years, 6 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.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 2 years, 6 months ago.

Author
Posts
#2355431

Whilst looking for a solution myself, I came across this post;

https://toolset.com/forums/topic/how-do-i-limit-the-number-of-posts-a-user-can-create/

I figured I would look for a way to accomplish this using toolset in it's current form.

This post is more of a guide for other people, rather than a support topic for help.

To limit the number of posts a user can make to 1 post per person per CPT, we need to hide the CRED form when a user has created a post already.

It's really simple and you'll probably kick yourself once you've read this article.
Anything above 1 will probably need custom code, as explained by Shane in the above post.

Let's say I have the following;

CPT - Profiles
CRED Form - Create a New Profile

I want to limit each person who signed up to my website to only be able to create just 1 profile.
Once that profile has been create, I do not want them to create anymore.

Firstly I will create a view which will show all results.
This view will be for the CPT Profiles.

This view is basically just to check if there is a post that exists.
Inside the loop, you can enter another view containing information or we will put something like;

<wpv-loop>
You have already created your profile, please view this <a href="[wpv-post-url]">here</a>
</wpv-loop>

Then below the loop we have the 'no items found section'

Here we are going to delete "No items found" and insert our CRED form 'Create a New Profile'

	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"][cred_form form="create-a-new-profile"][/wpml-string]</strong>
	[/wpv-no-items-found]

This view needs to be inserted into the page you would typically expect to see the CRED for to create a new profile.

There you go, you've now limited your guests on your website to posting 1 post with that CPT.

No extra code, no time wasted.

P.S. You can take it a step further and add filters to the form.

For example.

I have a listing site, the listing site allows people to sell property.
I only want them to have 1 property for sale/under offer/draft at any 1 time.
However, I would like to allow my users to submit a new property once they have marked their last property as sold.

So I have added a filter that searches for posts which are categorised under sold/under offer/draft.

Moving even further, I allow my users to edit their posts, whilst the property is not marked as sold.
Hiding the edit modal(once 'sold') the same way as we hide the form above, is a great way to give users correct access to posts, limit posts to 1 and also remove the possibility of them creating a loophole allowing them to create more than 1 post at a time.

I hope this helps other people.

Toolset is REALLY great, there's loads of potential that I haven't seen posted on these forums as of yet.

Anyway, take care.
Steve

#2355447

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Thanks for sharing that Steve 🙂