Forked from spivurno/gp-limit-submission-nested-forms-scope-feeds-to-parent-entry.php
Created
April 3, 2020 19:02
-
-
Save version-control/e75d5d4cf300c71b448a742c01c8d301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ) ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment