Skip to content

Instantly share code, notes, and snippets.

View saifsultanc's full-sized avatar
🏠
Remote

Saif Sultan saifsultanc

🏠
Remote
View GitHub Profile
<?php
<?php
/**
* Gravity Perks // Populate Anything // Recteurs d'Académie JSON
*/
class GPPA_Object_Type_Recteurs extends GPPA_Object_Type {
public function __construct( $id ) {
parent::__construct( $id );
@saifsultanc
saifsultanc / GWCalcSubtotal.php
Created November 8, 2025 15:37
GWCalcSubtotal.php
<?php
/**
* Gravity Wiz // Gravity Forms // Calculation Subtotal Merge Tag
* https://gravitywiz.com/subtotal-merge-tag-for-calculations/
*
* Adds a {subtotal} merge tag which calculates the subtotal of the form.
*
* This merge tag can only be used within the "Formula" setting of Calculation-enabled fields (i.e. Number, Calculated Product).
*
* Plugin Name: Gravity Forms Subtotal Merge Tag
@saifsultanc
saifsultanc / gpro-enable-when-dynamically-populated.php
Created November 6, 2025 15:34
gpro-enable-when-dynamically-populated.php
<?php
add_filter( 'gform_pre_render', function ( $form, $ajax, $field_values ) {
if ( ! session_id() ) {
session_start();
}
if ( ! isset( $_SESSION['gwreadonly_disabled_fields'] ) ) {
$_SESSION['gwreadonly_disabled_fields'] = array();
}
$gwreadonly_disabled_fields = $_SESSION['gwreadonly_disabled_fields'];
@saifsultanc
saifsultanc / gw-update-posts.php
Created October 1, 2025 09:47
ACF multi-selects and serialized data.
<?php
/**
* Gravity Wiz // Gravity Forms // Update Posts
* https://gravitywiz.com/how-to-update-posts-with-gravity-forms/
*
* Update existing post title, content, author and custom fields with values from Gravity Forms.
*
* @version 0.6
* @author Scott Ryer <[email protected]>
* @license GPL-2.0+
<?php
add_action( 'gform_after_update_entry', function ( $form, $entry_id ) {
$gppa_lmt = GP_Populate_Anything_Live_Merge_Tags::get_instance();
$entry = GFAPI::get_entry( $entry_id );
foreach ( $form['fields'] as $field ) {
// For any field having Live Merge Tags.
if ( $gppa_lmt->has_live_merge_tag( $field->defaultValue ) ) {
$gppa_lmt->populate_lmt_whitelist( $form );
remove_all_filters('gform_pre_replace_merge_tags');
@saifsultanc
saifsultanc / gpuid-generate-post-workflow.php
Created September 2, 2025 17:28
gp-unique-id/gpuid-generate-post-workflow.php
<?php
/**
* Gravity Perks // Unique ID // Conditional Unique ID for Gravity Flow
* https://gravitywiz.com/documentation/gravity-forms-unique-id/
*
* Instruction Video: https://www.loom.com/share/e799e8b4b0984d99a66da79faa34ffee
*
* Prevent a Unique ID field from generating its value until a specific Gravity Flow Workflow step is completed.
* Useful when you want to generate the Unique ID only after approval or other workflow steps.
*
@saifsultanc
saifsultanc / GW_Rename_Uploaded_Files.php
Created August 28, 2025 14:21
GW_Rename_Uploaded_Files.php
<?php
class GW_Rename_Uploaded_Files {
public $_args;
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(
'form_id' => false,
@saifsultanc
saifsultanc / 87744-snippet.php
Last active September 4, 2025 05:45
87744-snippet.php
<?php
class GPPA_Populate_Child_Entries {
public function __construct( $args = array() ) {
// do version check in the init to make sure if GF is going to be loaded, it is already loaded
add_action( 'init', array( $this, 'init' ) );
}
@saifsultanc
saifsultanc / gpeb-test-snippet.php
Created August 12, 2025 06:29
gpeb-test-snippet.php
<?php
add_filter( 'gform_pre_render', 'gpeb_remove_fields_on_edit' );
add_filter( 'gform_pre_process', 'gpeb_remove_fields_on_edit' );
function gpeb_remove_fields_on_edit( $form ) {
$is_block = (bool) rgpost( 'gpeb_entry_id' );
if ( ! $is_block ) {
$is_block = class_exists( 'WP_Block_Supports' ) && rgar( WP_Block_Supports::$block_to_render, 'blockName' ) === 'gp-entry-blocks/edit-form';
@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 );