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 / gpi_ignore_disabled_on_gravityview.php
Last active August 6, 2025 08:37
gpi_ignore_disabled_on_gravityview.php
<?php
add_filter( 'gform_field_content', function( $content, $field, $value, $lead_form_id ) {
if ( ! rgget( 'edit' ) || ! rgget( 'gvid' ) ) {
return $content;
}
libxml_use_internal_errors( true );
$doc = new DOMDocument();
$doc->loadHTML( '<?xml encoding="utf-8" ?>' . $content );
@saifsultanc
saifsultanc / gw-force-default-value.php
Created July 31, 2025 10:03
gravity-forms/gw-force-default-value.php
<?php
class GW_Force_Default_Value {
private $_args = array();
public function __construct( $args = array() ) {
// set our default arguments, parse against the provided arguments, and store for use throughout the class
$this->_args = wp_parse_args( $args, array(
@saifsultanc
saifsultanc / gfadvs-drag-and-drop-with-touch-support.js
Created July 24, 2025 06:08
gfadvs-drag-and-drop-with-touch-support.js
window.gform.addFilter(
'gpadvs_settings',
function(settings, gpadvsInstance, selectNamespace) {
if (gpadvsInstance.fieldType === 'multiselect') {
settings.plugins.drag_drop = {
title: 'Drag n Drop',
};
}
@saifsultanc
saifsultanc / gw-gravity-forms-emoji-handler.php
Created July 15, 2025 07:07
gw-gravity-forms-emoji-handler.php
<?php
/**
* Gravity Wiz // Gravity Forms // Remove or Validate Emojis ✮
*
* Automatically remove or provide a validation error when emojis are submitted via a Gravity Form field.
*
* @version 1.1
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
@saifsultanc
saifsultanc / gpapf-reset-phone-value-on-country-change.js
Created July 9, 2025 13:45
gpapf-reset-phone-value-on-country-change.js
jQuery(document).ready(function($) {
const PHONE_FIELD_ID = 2; // Phone Field ID
const $phoneInput = $(`#input_${GFFORMID}_${PHONE_FIELD_ID}_raw`);
const $countrySelector = $('.iti__selected-country-primary');
if (!$phoneInput.length || !$countrySelector.length) {
return;
}
@saifsultanc
saifsultanc / gpaa-geoencode-addresses.php
Created July 3, 2025 09:16
gpaa-geoencode-addresses.php
<?php
add_action( 'init', function() {
$form_id = 401; // Replace with your Form ID.
$field_id = 1; // Replace with your Address Field ID.
$api_key = 'YOUR_GOOGLE_API_KEY'; // Replace with your Google Maps API Key.
if ( ! class_exists( 'GFAPI' ) ) {
return;
@saifsultanc
saifsultanc / count-number-of-characters.js
Last active June 6, 2025 10:56
count-number-of-characters.js
// Customize field IDs and offset
const fieldIds = [1, 2, 3, 4]; // Text fields
const targetFieldId = 5; // Number field to hold total count.
const offset = -1000; // Offset value (Can be positive or negative)
const getInputSelector = (id) => `#input_${GFFORMID}_${id}`;
const targetSelector = getInputSelector(targetFieldId);
function updateCharacterCount() {
let total = 0;
@saifsultanc
saifsultanc / gcoai-stream-to-paragraph-field.js
Created June 4, 2025 13:38
gc-openai/gcoai-stream-to-paragraph-field.js
/**
* Gravity Connect // OpenAI // Stream to Paragraph Field (Multi-field Support)
* https://gravitywiz.com/documentation/gravity-connect-openai/
*
* Stream OpenAI responses from multiple Stream fields to Paragraph or Single Line Text fields.
* Users can edit the final result.
*/
const streamFieldMappings = [
{
@saifsultanc
saifsultanc / gpmpn-dropdown-navigation.js
Last active June 9, 2025 07:34
gp-multi-page-navigation/gpmpn-dropdown-navigation.js
/**
* Gravity Perks // Multi-page Navigation // Dropdown Navigation
* https://gravitywiz.com/documentation/gravity-forms-multi-page-navigation/
*
* Instruction Video: https://www.loom.com/share/38fcc941036842d6a81a599fd8de39d7
*
* This snippet is designed to be used with the Gravity Forms Code Chest plugin.
* https://gravitywiz.com/gravity-forms-code-chest/
*/
const pageNameTemplate = 'Step {pageNumber}: {pageName}';
@saifsultanc
saifsultanc / gpeb_queryer_entries-multi-field-sorting.php
Last active May 21, 2025 02:00
gpeb_queryer_entries-multi-field-sorting.php
<?php
add_filter( 'gpeb_queryer_entries', function( $entries, $gf_queryer ) {
// Update the form ID to match your form.
if ( $gf_queryer->form_id != 933 ) {
return $entries;
}
// Update the field IDs to match your form.