Title: Limit Forms Post
Last modified: December 5, 2019

---

# Limit Forms Post

 *  Resolved [MoLy](https://wordpress.org/support/users/dionix/)
 * (@dionix)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/limit-forms-post/)
 * Can this be done with ACF EXTENDED?
 * Limit the publication of forms from the frontend to a specific amount according
   to the user role.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * (@hwk-fr)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/limit-forms-post/#post-12212102)
 * Hello,
 * This is more a page display restriction problem than form restriction. Because
   one ACF Extended Form can do 50 differents actions with one single submission(
   add posts, update an another etc…). I could add some restrictions conditions 
   in the form setting, but it could quickly become very complex:
 * Hide form if user role X has more than 5 posts in the post type Y within the 
   last 24 hour. etc…
 * Also, if I add UI for restrictions, maybe it should be added to form actions (
   micro management) instead of global form setting (macro management). Maybe some
   users would like to restrict actions instead of whole form display. It’s complicated
   to find the perfect solution. It should be very flexible to fulfil everyone’s
   needs.
 * The best way to achieve it, is by writing your own PHP condition on the page 
   that call the form. You have to count the current user posts and check if it’s
   higher than your limit.
 * Here is a code example:
 *     ```
       $user = wp_get_current_user();
   
       // Check if current user has role 'author'
       if(in_array('author', (array) $user->roles)){
   
           // Get posts of the current user (by post_author)
           $check_posts = get_posts(array(
               'post_type'         => 'my_post_type',
               'post_author'       => get_current_user_id(),
               'posts_per_page'    => -1,
               'fields'            => 'ids'
           ));
   
           // Display form if the current has less than 5 posts
           if(count($check_posts) < 5){
   
               // Call my form
               acfe_form('my-form');
   
           }else{
   
               ?>
               <h3>You already posted more than 5 posts.</h3>
               <?php
   
           }
   
       }
       ```
   
 * I haven’t tested the code, but it should work.
 * Hope it helps!
 * Regards.

Viewing 1 replies (of 1 total)

The topic ‘Limit Forms Post’ is closed to new replies.

 * ![](https://ps.w.org/acf-extended/assets/icon-256x256.png?rev=2071550)
 * [Advanced Custom Fields: Extended](https://wordpress.org/plugins/acf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/acf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/acf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/acf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/acf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/acf-extended/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/limit-forms-post/#post-12212102)
 * Status: resolved