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 / 75526-snippet.php
Created December 23, 2024 16:57
75526-snippet.php
<?php
add_action( 'gpeb_edit_entry', function( $entry, $form ) {
// Update to your form_id and field_id
$form_id = 1;
$field_id = 4;
$meta_key = 'gallery_test';
global $wpdb;
if ( $form['id'] != $form_id ) {
window.gform.addAction('gpfup_before_upload', (formId, fieldId, file, up, gpfupInstance) => {
// Define allowed aspect ratios
const allowedAspectRatios = [
16 / 9, // 16:9
9 / 16, // 9:16
1 / 3, // 1:3
3 / 1 // 3:1
];
// Define allowed video MIME types
@saifsultanc
saifsultanc / gpfup-limit-duration-of-mp4-mov-files-to-multiple-fields.js
Last active November 20, 2024 15:32
gpfup-limit-duration-of-mp4-mov-files-to-multiple-fields.js
/**
* Gravity Perks // File Upload Pro // Limit Duration of MP4/MOV Files - Apply different limit to different different fields.
* https://gravitywiz.com/documentation/gravity-forms-file-upload-pro/
*
* Instructions:
* 1. Install our free Custom Javascript for Gravity Forms plugin.
* Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
*
* Demo: https://www.loom.com/share/9d72eea07e944f69bce5d3377b478a48
<?php
class GW_GPAPF_Formatting {
private $_args = array();
public function __construct( $args = array() ) {
$this->_args = wp_parse_args( $args, array(
'form_id' => false,
'field_id' => false,
gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
if (formId != GFFORMID && fieldId != '1') { // REPLACE 1 with your field id
return;
}
let value = $(elem).val();
if (value.length >= 2 && value.charAt(0) !== '0') {
value = '0' + value;
}
if (value.length >= 12 && value.charAt(0) === '0') {
value = value.substring(1);
<?php
// REPLACE "123" to the ID of your Form
add_action( 'gform_pre_submission_123', 'gw_capitalize_submitted_data' );
function gw_capitalize_submitted_data( $form ) {
$applicable_input_types = array( 'address', 'text', 'textarea', 'name', 'list' );
// REPLACE 9 with the List Field ID you intend to capitalize data for.
$target_list_field_id = 9;
foreach ( $form['fields'] as $field ) {
@saifsultanc
saifsultanc / gppa-filter-advanced-select-search.php
Created October 31, 2024 15:30
gppa-filter-advanced-select-search.php
<?php
add_filter( 'gppa_object_type_query', function ( $query_builder_args, $args ) {
global $wpdb;
if ( ! wp_doing_ajax() || rgar( $_REQUEST, 'action' ) !== 'gp_advanced_select_get_gppa_results' ) {
return $query_builder_args;
}
$(document).ready(function() {
var streamFieldId = 3;
var promptFieldId = 1;
var responseFieldId = 4;
var appendButtonFieldId = responseFieldId;
var $streamFieldInput = $(`#input_GFFORMID_${streamFieldId}`);
var $streamButton = $streamFieldInput.closest('.gfield').find('.gcoai-trigger');
var $promptInput = $(`#input_GFFORMID_${promptFieldId}`);
var $newButton = $streamButton.clone()
@saifsultanc
saifsultanc / gcoai-snippet.php
Created October 28, 2024 12:10
gcoai-snippet.php
<?php
var streamFieldId = 3;
var promptFieldId = 1;
var responseFieldId = 4;
var appendButtonFieldId = responseFieldId;
var $streamFieldInput = $(`#input_GFFORMID_${streamFieldId}`);
var $streamButton = $streamFieldInput.closest('.gfield').find('.gcoai-trigger');
$streamFieldInput.on('change', function() {
<?php
/**
* Gravity Wiz // Gravity Forms // Update Posts (Customized with POST ID)
* 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+