Skip Navigation

[Resolved] Content Restrictions

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 3 replies, has 2 voices.

Last updated by Shane 3 months ago.

Assigned support staff: Shane.

Author
Posts
#2035621

Tell us what you are trying to do?
- We have a customer who is a realtor company and needs to limit the number of "listings" per realtor account created that is displayed.

For example, Realtor "A" will only have the ability to post 10 listings. Is this possible within the toolset settings?

Is there any documentation that you are following? no

Is there a similar example that we can see? not sure

What is the link to your site? not available yet

#2035869

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Philip,

Thank you for getting in touch. Will this be a case where you will be restricting by individual users?

Or will this just be based on the user's role. Secondly will this be for creating the posts on the frontend ? Or will this be backend only.

Please let me know as we can provide a solution for this but we need the exact scenario.

Thanks,
Shane

#2035983

Hello Shane,

Each realtor will login to the front end of the site and be able to add a property.

We would like to restrict the property number that can be added to 10.

#2036057

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2021-04-28 at 3.33.00 PM.png

Hi Philip,

I'm assuming here that you've added the form to your page using the Toolset Forms Block correct?

If so then you will need to add a conditional block to your template and then inside that Conditional block you re-add your form.

Now for the conditional block you will need the use of the following function.


function current_user_post_count() {

	$current_user_id = get_current_user_id();
	$posts_count = count_user_posts($current_user_id, 'car');
	return $posts_count;

}
add_shortcode( 'current_user_post_count', 'current_user_post_count' );

Add the above to Toolset->Settings->Custom Code and activate it. Then go to Toolset -> Settings -> Frontend and add "current_user_post_count" to the 3rd party shortcode arguments.

Finally go to the page that you've added the form and add the conditional block and set the conditional for the conditional block. See My Screenshot

Once you've done this the form should only show when the user has 10 or less posts.

Thanks,
Shane