Skip to content

Instantly share code, notes, and snippets.

View saifsultanc's full-sized avatar
🏠
Remote

Saif Sultan saifsultanc

🏠
Remote
View GitHub Profile
@saifsultanc
saifsultanc / gpld-populate-new-minimum-date-into-linked-date-field.js
Created May 20, 2025 10:28
gpld-populate-new-minimum-date-into-linked-date-field.js
const sourceFieldId = 37; // Replace with the ID of the source field (Field A)
// Track completion of required events
let postRenderComplete = false;
let minDateComplete = false;
let formId;
let calculationTimeout;
function checkAndRunCalculations() {
if (postRenderComplete && minDateComplete) {
@saifsultanc
saifsultanc / gw-snippet-gcgs_gppa_query_builder_args-78195.php
Created April 16, 2025 06:37
gw-snippet-gcgs_gppa_query_builder_args-78195.php
<?php
add_filter( 'gcgs_gppa_query_builder_args', function( $query_builder_args, $args, $object ) {
/** @var string|string[] */
$filter_value = null;
/** @var array */
$filter = null;
/** @var int */
$filter_group_index = null;
@saifsultanc
saifsultanc / test.php
Created April 14, 2025 09:39
test.php
<?php
add_action( 'gform_entry_post_save', function( $entry ) {
$form = GFAPI::get_form( $entry['form_id'] );
foreach ( $form['fields'] as $field ) {
if ( $field->get_input_type() === 'html' ) {
// Save HTML field content into entry meta
gform_update_meta( $entry['id'], 'html_field_' . $field->id, $field->content );
}
}
@saifsultanc
saifsultanc / gwiz_entry_count_shortcode_excluding_unsubscribed.php
Created April 8, 2025 05:42
gwiz_entry_count_shortcode_excluding_unsubscribed.php
<?php
add_filter( 'gform_shortcode_entry_count', 'gwiz_entry_count_shortcode', 10, 2 );
function gwiz_entry_count_shortcode( $output, $atts ) {
$email_field_id = 1; // Replace with your the email field ID.
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
extract( shortcode_atts( array(
'id' => false,
'status' => 'total', // accepts 'total', 'unread', 'starred', 'trash', 'spam'
'format' => false, // should be 'comma', 'decimal'
@saifsultanc
saifsultanc / custom-snippet-79632.php
Created April 3, 2025 05:07
custom-snippet-79632.php
<?php
add_filter( 'gform_replace_merge_tags', function ( $text, $form, $entry ) {
$pick = '';
if ( $text == '@{:1} @{:3} @{:10}' ) {
$trigger_field_id = 8;
$trigger_field_value = rgpost( 'input_' . $trigger_field_id );
if ( $trigger_field_value == 'First Choice' ) {
$pick = '1';
@saifsultanc
saifsultanc / gwaft_template_showhidden.php
Created March 29, 2025 09:06
gwaft_template_showhidden.php
<?php
add_filter( 'gwaft_template_output', function( $content, $slug, $name, $data, $suffixes ) {
if ( ! in_array( 'showhidden', $suffixes, true ) ) {
return $content;
}
$items = array();
foreach ( $data['form']['fields'] as $field ) {
$items[] = array(
'label' => $field->label,
@saifsultanc
saifsultanc / gcgs_gppa_query_builder_args.php
Created March 21, 2025 12:21
gcgs_gppa_query_builder_args.php
<?php
add_filter( 'gcgs_gppa_query_builder_args', function( $query_builder_args, $args, $object ) {
/** @var string|string[] */
$filter_value = null;
/** @var array */
$filter = null;
@saifsultanc
saifsultanc / gcgs-gppa-custom-query-builder-args.php
Last active March 13, 2025 10:09
gc-google-sheets/gcgs-gppa-custom-query-builder-args.php
<?php
add_filter( 'gcgs_gppa_query_builder_args', function( $query_builder_args, $args, $object ) {
/** @var string|string[] */
$filter_value = null;
/** @var array */
$filter = null;
@saifsultanc
saifsultanc / gw-conditional-read-only.php
Created February 26, 2025 01:47
gw-conditional-read-only.php
<?php
/**
* Gravity Wiz // Gravity Forms // Conditional Readonly Fields
* https://gravitywiz.com/
*
* This simple snippet will mark a field as readonly if a given source field has a specific value.
*
* Instructions:
*
* 1. Install this snippet with our free Code Chest plugin.
@saifsultanc
saifsultanc / 76963.php
Created February 11, 2025 07:01
76963.php
<?php
add_filter( 'gppa_get_batch_field_html', 'capture_acf_address_new', 10, 6 );
function capture_acf_address_new( $html, $field, $form, $fields, $entry_id, $hydrated_field ) {
// Replace 5 with your form id and 3 with your ACF address field id
if ( $form['id'] != 6 && $field['id'] != 3 ) {
return $html;
}
// Replace 1 with the field id of the field you have used for Field Value Object
$post_id = rgpost( 'input_1' );