Skip to content

Instantly share code, notes, and snippets.

@matty0501
matty0501 / gpeb-navigation-with-filtered-choices.php
Last active October 2, 2024 07:46 — forked from saifsultanc/gpeb-navigation-with-filtered-choices.php
gpeb-navigation-with-filtered-choices.php
<?php
// helper method
function get_array_subset( $array, $offset, $limit ) {
if ( $offset > count( $array ) - 1) {
return [];
}
$start = $offset;
$length = min( $limit, count( $array ) - $offset );
return array_slice( $array, $start, $length );
<?php
/**
* Gravity Wiz // Gravity Forms // URL Encode Merge Tag Modifier
* https://gravitywiz.com
*
* Use the :url_encode modifier on merge tags to URL encode the value
*
* this: Advanced Save & Continue
* to: Advanced+Save+%26+Continue
*/
<?php
/**
* Gravity Perks // Populate Anything // LMT URL Encode Characters
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* URL encode characters when populating a Live Merge Tag
*/
// Update "123" to your form ID; and "4" to the field you are copying from.
add_filter( 'gppa_live_merge_tag_value_123_4', function( $value ) {
return urlencode( $value );
<?php
/**
* Gravity Perks // Populate Anything // LMT Extract First Letter
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* 🦄 This has now been added to the Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-populate-anything/gppa-lmt-extract-first-character.php
*
* Extract the first letter of a string using a Live Merge Tag
*/
/**
* Gravity Perks // Nested Forms // Copy Parent Values To First Child Entry
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Copy parent values into the first child entry automatically. The `{Parent}` merge tag would typically be used
* for this but this would copy the values to all child entries, not just the first.
*/
gform.addAction( 'gpnf_init_nested_form', function( childFormId, gpnf ) {
// Update "123" to your the ID of your child form.
<?php
/**
* Gravity Perks // Nested Forms // Add `Required` label to Nested Form field
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Adds a `Required` label to a Nested Form field when a minimum child entry limit is set.
*/
// Replace `123` with your form ID and `4` with your Nested Form field ID
add_filter( 'gform_field_content_123_4', function ( $content, $field, $value, $lead_id, $form_id ) {
<?php
/**
* Gravity Perks // Notification Scheduler // Custom Repeat Schedule
* https://gravitywiz.com/documentation/gravity-forms-notification-scheduler/
*/
add_filter( 'gpns_schedule_timestamp', function ( $timestamp, $notification, $entry, $is_recurring, $current_time ) {
// Update "123" to the form ID.
$form_id = 123;
<?php
/**
* Gravity Perks // Address Autocomplete // Update GravityView Geocoder with coordinates
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete/
*/
// Replace 123 with your form ID
add_action( 'gform_after_submission_123', function ( $entry, $form ){
$address_field_id = 4; // Replace 4 with your address field ID
$lat_field_id = 6; // Replace 6 with your latitude field ID
<?php
/**
* Gravity Shop // GS Product Configurator // Don't Delay User Registration Feed
*
* Instructions:
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
*/
add_filter( 'gspc_delay_feed_processing', function( $delay, $form, $entry, $slug, $payment_feed ){
if( $slug === 'gravityformsuserregistration' ){
<?php
/**
* Gravity Perks // Populate Anything // Populate JetSloth with ACF Image Field
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* Instructions:
*
* 1. Go to the field settings for the Gravity Forms choice field you are populating.
* 3. Add "gppa-jetsloth-acf-image" to the "Custom CSS Class" setting (on the Appearance tab).
*