Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Gravity Perks // Populate Anything // Use Standard Merge Tags in Choice/Value Templates
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gppa_process_template', function( $template_value, $field, $template, $populate, $object, $object_type, $objects ) {
return GFCommon::replace_variables( $template_value, GFAPI::get_form( $object->form_id ), (array) $object );
}, 10, 7 );
<?php
/**
* Gravity Perks // Populate Anything // Set Post Taxonomy Terms
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gform_after_create_post', function( $post_id, $entry, $form ) {
foreach( $form['fields'] as &$field ) {
if( is_callable( 'gp_populate_anything' ) && $field->{'gppa-choices-enabled'} && $field->{'gppa-choices-object-type'} == 'term' ) {
$value = gp_populate_anything()->get_field_value( $form, $entry, $field->id );
@spivurno
spivurno / gp-limit-submissions-apply-same-feed-to-group.php
Last active September 14, 2021 12:59
Gravity Perks // GP Limit Submissions // Apply Limit Feed to Group of Forms
<?php
/**
* Gravity Perks // GP Limit Submissions // Apply Limit Feed to Group of Forms
* http://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*/
add_filter( 'gpls_rule_groups', function( $rule_groups, $form_id ) {
// Update "123" to the ID of your form.
$primary_form_id = 123;
<?php
/**
* Gravity Perks // Limit Choices // Fix Conflict with GF Real Time Validation
* http://gravitywiz.com/documentation/gravity-forms-limit-choices/
*/
if( class_exists( 'Gravity_Forms_Live_Validation' ) ) {
$gf_live_validation = Gravity_Forms_Live_Validation::get_instance();
remove_filter( 'gform_pre_render', array( $gf_live_validation, 'lv_apply_validations_to_form' ) );
add_filter( 'gform_pre_render', array( $gf_live_validation, 'lv_apply_validations_to_form' ), 11 );
}
<?php
/**
* Gravity Perks // Populate Anything // Populate User Role
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gppa_process_template', function( $value, $field, $template, $populate, $object, $object_type, $objects ) {
if( $template == 'role' && is_a( $object, 'WP_User' ) ) {
$value = implode( ', ', $object->roles );
}
return $value;
<script type="text/javascript">
gform.addFilter( 'gppc_copied_value', function( value, $elem, data ) {
// Update "1" to the ID of the field being copied to.
if( data.target == 1 && value ) {
value = value.split( '|' )[0];
}
return value;
} );
<?php
/**
* Gravity Perks // Nested Forms // Delay Child Notifications for Parent Payment
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gpnf_should_send_notification', function( $should_send_notification, $notification, $context, $parent_form, $nested_form_field, $entry, $child_form ) {
if( $context == 'parent' ) {
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
$should_send_notification = in_array( rgar( $parent_entry, 'payment_status' ), array( 'Paid', 'Active' ) );
<?php
/**
* Gravity Perks // Populate Anything // Populate Post Meta as Choices
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
// Update "123" with your form ID; Update "4" with your field ID.
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) {
$custom_field = str_replace( 'meta_', '', $field['gppa-choices-templates']['label'] );
$meta = get_post_meta( $objects[0]->ID, $custom_field );
<?php
/**
* Gravity Perks // Multi-page Navigation // Bypass Validation on Next
* https://gravitywiz.com/documentation/gravity-forms-multi-page-navigation/
*
* Bypass validation when clicking the next button. Navigation Activation Type must be set to "from the start".
*/
add_filter( 'gform_form_tag', function( $tag ) {
$tag .= '<input type="hidden" name="gw_bypass_validation" value="1">';
return $tag;