<?php
/**
* Gravity Perks // Limit Submissions + Nested Forms // Scope Limit Feeds to Current Parent Entry
* http://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*/
add_action( 'gpls_before_query', function( $ruletest ) {
global $wpdb;
// Update "123" to your child form ID.
if( $ruletest->form_id == 123 && class_exists( 'GPNF_Session' ) && $parent_form_id = rgpost( 'gpnf_parent_form_id' ) ) {
$gpnf_session = new GPNF_Session( $parent_form_id );
$ruletest->join[] = "INNER JOIN {$wpdb->prefix}gf_entry_meta em_gpnf ON em_gpnf.entry_id = e.id";
$ruletest->where[] = sprintf( "\n( em_gpnf.meta_key = '%s' AND em_gpnf.meta_value = '%s' )", GPNF_Entry::ENTRY_PARENT_KEY, $gpnf_session->get( 'hash' ) );
}
} );