Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Gravity Perks // Nested Forms // Hourly Cron & Orphaned Entry Expiration
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
function gpnf_custom_hourly_cron() {
if( ! is_callable( 'gp_nested_forms' ) ) {
return;
}
<?php
/**
* Gravity Perks // Limit Submissions // Value-specific Limits by Field
* http://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*
* Form Export: https://gwiz.io/2Nm2JC2
* Feed Config: https://gwiz.io/2GJ2mRV
*/
// Update "123" to your form ID.
add_filter( 'gpls_rule_groups_123', function( $groups ) {
@lukecav
lukecav / Command
Created February 19, 2019 19:04
Migrating your Media to S3 using S3 Uploads plugin from Human Made
wp s3-uploads migrate-attachments --delete-local
@zackkatz
zackkatz / gravityview-trigger-gform_after_submission-form-12.php
Last active July 3, 2023 22:38
GravityView - Trigger the `gform_after_submission` action when an entry is edited, but ONLY for Form #12.
<?php
/**
* GravityView doesn't trigger the `gform_after_submission` action when editing entries. This does that,
* but ONLY FOR FORM #12.
*
* @param array $form
* @param int $entry_id ID of the entry being updated
* @param GravityView_Edit_Entry_Render $object
*
<?php
/**
* Gravity Perks // Nested Forms // Re-order Display Fields
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
// Update "123" to your form ID.
add_filter( 'gform_pre_render_123', function( $form ) {
foreach( $form['fields'] as &$field ) {
// Update "2" to your Nested Form field ID.
if( $field->id = 2 ) {
<?php
/**
* Gravity Perks // Nested Forms // Copy Parent Entry Properties on Parent Form Submission
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
// Update "123" to your parent form ID.
add_action( 'gform_entry_created_123', function( $entry, $form ) {
// Specify which properties you would like to populate from the parent.
// Supports: id, form_id, post_id, date_created, is_starred, is_read, ip, source_url, user_agent, currency, payment_status, payment_date, payment_amount, payment_method, transaction_id, is_fulfilled, created_by, transaction_type, status, date_updated, last_payment_date
@yanknudtskov
yanknudtskov / functions.php
Created January 28, 2019 13:15
Exclude categories from WooCommerce Dropdowns and Category (Product) Archives. This example assumes there's added a custom field, but can easily be modified to suit your needs.
<?php
add_filter( 'woocommerce_product_categories_widget_args', 'yanco_woocommerce_product_categories_widget_args', 10, 1 );
add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'yanco_woocommerce_product_categories_widget_args', 10, 1 );
function yanco_woocommerce_product_categories_widget_args( $list_args ) {
$exclude_array = array();
$exclude_args = array(
'taxonomy' => 'product_cat',
'meta_query' => array(
@zackkatz
zackkatz / gravityview-modify-rest-response.php
Created December 18, 2018 20:10
GravityView - Modify the REST response sent by GravityView to use Gravity Forms field labels instead of just the field IDs
<?php
/**
* Modify the REST response sent by GravityView to use GF form field labels instead of field IDs
*/
add_filter( 'rest_pre_echo_response', function( array $result, WP_REST_Server $server, WP_REST_Request $request ) {
if ( empty( $result['entries'] ) ) {
return $result;
}
@spivurno
spivurno / gp-ecommerce-fields-set-tax-amount-dynamically.php
Last active November 22, 2021 20:32
Gravity Perks // GP eCommerce Fields // Set Tax Amount Dynamically
<?php
/**
* Gravity Perks // GP eCommerce Fields // Set Tax Amount Dynamically
* https://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
*/
add_filter( 'gform_pre_render_123', 'gpecf_dynamic_tax_amount' );
add_filter( 'gform_pre_validation_123', 'gpecf_dynamic_tax_amount' );
add_filter( 'gform_pre_submission_filter_123', 'gpecf_dynamic_tax_amount' );
add_filter( 'gform_admin_pre_render_123', 'gpecf_dynamic_tax_amount' );
function gpecf_dynamic_tax_amount( $form ) {
@zackkatz
zackkatz / gravityview-auto-unapprove-gf.php
Created November 30, 2018 18:02
GravityView - Auto-reset GravityView entry approval when editing an entry in Gravity Forms or using the Gravity Forms API
<?php
/**
* When an entry is updated in Gravity Forms Edit Entry or Gravity Forms API, unapprove it
*/
add_action( 'gform_after_update_entry', function( $form, $entry_id, $original_entry ) {
if ( ! is_admin() ) {
// return; # Uncomment if you want to run this only in the Edit Entry screen, not also in API requests
}