Title: Adding entry conditionally
Last modified: August 22, 2016

---

# Adding entry conditionally

 *  Resolved [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/)
 * I’m trying to figure out how to add a link so that a user can add a record ONLY
   if they don’t already have one. Is there a shortcode I could use to wrap an ADD
   RECORD link in that conditional logic?
 * [https://wordpress.org/plugins/gravity-forms-sticky-list/](https://wordpress.org/plugins/gravity-forms-sticky-list/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/#post-5769130)
 * Yes. I have a code snippit you could use to achieve this. I’ll post it here later
   today.
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/#post-5769152)
 * Sorry for the late reply. Here is some code you can use. This function will return
   the number of entries that the currently logged in user has mad for a specific
   form. Put this into functions.php
 *     ```
       function count_user_submissions($form_id) {
       	global $current_user;
       	get_currentuserinfo();
       	$search_criteria["field_filters"][] = array("key" => "status", "value" => "active");
       	$search_criteria["field_filters"][] = array("key" => "created_by", "value" => $current_user->ID);
       	$sorting = array();
           $paging = array('offset' => 0, 'page_size' => 999999 );
       	$leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
       	return count($leads);
       }
       ```
   
 * Then, in your template file you could do something like this.
 *     ```
       if (count_user_submissions($form_id) < 1) {
       	echo do_shortcode( "[stickylist id='$form_id']");
       }
       ```
   
 * You need to change “$form_id” above to the ID of the form. The above shows the
   form only is the user has made no entries in the form.
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/#post-5769165)
 * I hope the above code helped you to solve this. I’ll mark this topic as resolved.
   You can re-open it if you still have questions regarding this.
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/#post-5769184)
 * Thanks for posting this. Which instance of “$form_id” needs to be changed? I’m
   assuming it’s in the second snippet. I’ve updated the shortcode:
 *     ```
       echo do_shortcode( "[stickylist id='5']");
       ```
   
 * But that doesn’t seem to do it.
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/#post-5769186)
 * You need to put the first code snippit in your functions.php and the second in
   your template file where you want the list to appear. Include the full second
   code snippit and replace both instances of $form_id in it.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding entry conditionally’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/gravity-forms-sticky-list_9b65b3.
   svg)
 * [Gravity Forms Sticky List](https://wordpress.org/plugins/gravity-forms-sticky-list/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-sticky-list/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-sticky-list/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-sticky-list/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-sticky-list/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-sticky-list/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/adding-entry-conditionally/#post-5769186)
 * Status: resolved