Aleš Sýkora wrote

Limit Toolset Form to one submission per user only

25. 6. 2021 in

The easiest way to enable user submit only one post is to hide the form when they already submitted it. So you need to count the number of posts user created and if it is more than 1 then with conditional hide the form.

  1. Check the number of posts user created with custom function
 *Count posts of given type, so each user can create post only once
function twiki_post_count() {
    $your_current_user_id = get_current_user_id();
    return count_user_posts( $your_current_user_id , "your-post-type-slug" , false );

3. Add function twiki_post_count then need to be added to Toolset > Settings > Front End Content > Functions inside conditional evaluations:

Adding function to be used in conditionals in Toolset

4. Then use conditional to restrict the content

[wpv-conditional if="( twiki_post_count() lt '1' )"]
 This user can add this post type currently. Toolset form will be displayed.

You can also use this function in Oxygen Builder custom conditional PHP function value (without need to adding in toolset setting).

2 comments on “Limit Toolset Form to one submission per user only”

  1. Hello, it is not working for me, it still shows the form.
    [wpv-conditional if=”( twiki_post_count() lt ‘1’ )”]

    is there a capital letter there?

    1. Hello Gabriel, are u using the right Quotes? Did you followed all steps? Point 3 is needed, do not forget!

      However, you can try if the function itself works with php. Add following code in PHP to your page:

      echo twiki_post_count();

      It should return the number of posts. If that works, then problem is something else. But I suggest to start with this test.

      regards, Aleš

Leave a Reply to Aleš Sýkora Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
How to use Animate On Scroll Library with Oxygen Builder
9. 8. 2021 in
Animate on scroll library (AOS) is easy to use CSS driven on scroll animation library. Plugin logic is in .JS, animations in .CSS. You can read more about AOS on CSS tricks and of course on AOS on GitHub. UPDATE: I found this is already included in oxygen LOL :-D. You need to go to […]
Read More
Aleš Sýkora wrote
Dequeue WooCommerce JS and CSS
If you do not use default WooCommerce Photoswipe lightbox, flexslider and other libraries, you can dequeue them for faster loading of your site. I am doing that especially when I use the Oxygen Builder because in most times I build my own product galleries with fancybox. How to do Dequeue WooCommerce JavaScripts and CSS styles? […]
Read More
Aleš Sýkora wrote
Get WordPress title for page, post, category, archive in Oxygen
26. 1. 2021 in ,
Want to create only one template for Header and Footer – the main template – in Oxygen sometimes? So You need to display the title of current page, post, archive, category in one place. It cannot be done with Oxygen conditionals :(. So you have to make it done with code block and custom PHP. […]
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram