Last active
April 29, 2020 06:42
-
-
Save spivurno/53d5d86b030ec0a434e4a34d92034680 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