Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author fried_eggz

    (@fried_eggz)

    Yes. I have a code snippit you could use to achieve this. I’ll post it here later today.

    Plugin Author fried_eggz

    (@fried_eggz)

    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

    (@fried_eggz)

    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

    (@metaglyphics)

    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

    (@fried_eggz)

    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.