gpls_before_query
Description
Do something (like modify the GPLS_RuleTest object) before the query is executed.
Usage
add_action( 'gpls_before_query', 'my_custom_function' );Parameters
gpls_rule_test \GPLS_RuleTest
The current instance of the GPLS_RuleTest object.
Since
This action is available since Gravity Forms Limit Submissions 1.0-beta-1.20.
Examples
Set Limit Period by User Meta
Scope Feeds to the Current Nested Forms Parent Entry
Configure a Limit Submissions feed for a child form and then scope that feed to only apply to child entries submitted for the same parent entry.
For example, if we create a Limit Submissions feed that limits by the field value of a Name field, “David Smiff” could not be specified in this field for two child entries of the same parent entry. However, if I submitted a second parent entry, I could enter “David Smiff” as a child entry again.
<?php
/**
* Gravity Perks // Limit Submissions // Scope Feeds to the Current Nested Forms Parent Entry.
* https://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*
* Set GP Limit Submissions feed to only apply to child entries submitted for the same parent entry.
*/
add_action( 'gpls_before_query', function( $ruletest ) {
global $wpdb;
$parent_form_id = rgpost( 'gpnf_parent_form_id' );
// Update "123" to your child form ID.
if ( $ruletest->form_id == 123 && class_exists( 'GPNF_Session' ) && $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' ) );
}
} );