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

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
Properly align Checkbox in Astra theme
4. 7. 2019 in
Hello, today I found that Astra theme incorrectly displays Toolset form checkbox. This is fast repair:
Read More
Aleš Sýkora wrote
Bootstrap 4 button line break
11. 11. 2019 in
Break the line of long text in Bootstrap 4 button on mobile device.
Read More
Aleš Sýkora wrote
Oxygen two columns woocommerce checkout
23. 4. 2020 in ,
CSS Fix for Woocommerce checkout page in Oxygen Builder.
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram