Skip to content

Instantly share code, notes, and snippets.

View yellowstonebum's full-sized avatar

Parkbum yellowstonebum

View GitHub Profile
@yellowstonebum
yellowstonebum / functions.php
Last active March 12, 2020 15:00
Function file for SO
<?php
function gaws_edit_entry( $entry, $form ) {
$form_id = $form['id'];
if( $form_id == 2 ){
$data = array();
$csv0 = array(
array(
'Client ID',
@yellowstonebum
yellowstonebum / add_entry.php
Last active February 12, 2019 23:28
Gravity Forms - Example of adding an Entry from a snippet
$entry = array(
'form_id' => $form_id,
'date_created' => $today,
'is_starred' => 0,
'is_read' => 1,
'created_by' => $user_id,
'status' => 'active',
'payment_status' => 'Commission',
'6' => 'Admin',
'13' => $company_name,
@yellowstonebum
yellowstonebum / max_submissions.php
Last active December 19, 2018 17:38
Gravity Form - Max Submissions
<?php
// created by [email protected]
// for Gravity Forms
// add to functions or to snippet plugin
// NEEDS - On line 15, add max allowed for what you want the redirect to do
// CUSTOMIZING - For certain forms, change '{form_id}' or add a conditional statement
add_filter( 'gform_pre_render_{form_id}', 'gf_form_count_{form_id}' );
function gf_form_count_{form_id}($form){
// Change per form
$user_id = get_current_user_id();
@yellowstonebum
yellowstonebum / populate_list_passthrough.php
Last active September 18, 2018 15:49
Gravity Forms - Populate Column with Entry Data - Simple
<?php
// The following snippet will populate a List Field's dropdown with another forms entries.
// Direct the snippet to populate the field with "gform_column_input_42_1_4". 42 being the
// field, 1 being the field, and 4 being the column
// BE AWARE - changing the column in the list field will break this snippet
add_filter( 'gform_column_input_42_1_4', 'feature_column', 10, 5 );
function feature_column( $input_info, $field, $column, $value, $form_id ) {
// Input the form ID that you wish to pull from. For me that was field 7
$form_id = 7;
$entries = GFAPI::get_entries( $form_id );
@yellowstonebum
yellowstonebum / populate_list_usermeta.php
Last active September 18, 2018 15:50
Gravity Forms - Populate Column with User Meta - Simple
<?php
// The following snippet will populate a List Field's dropdown with another forms entries.
// Direct the snippet to populate the field with "gform_column_input_42_1_3". 42 being the
// field, 1 being the field, and 3 being the column
// BE AWARE - changing the column in the list field will break this snippet
add_filter( 'gform_column_input_42_1_3', 'business_column', 10, 5 );
function business_column( $input_info, $field, $column, $value, $form_id ) {
$items = array();
// Input the type of meta you want to look got and the defining result. For me this was users with the role of "company".
$metas = get_users( array( 'role' => 'company' ) );
// Creating a chain select for a Gravity Forms List Field - https://docs.gravityforms.com/gf_field_list/
// TO-DO - Populate Column 3 "Company" with user display_names that have the role of 'company'
// Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displayed when editing the entry.
add_filter( 'gform_entries_column_filter', 'populate_complist', 10, 5 );
add_filter( 'gform_column_input', 'populate_complist', 10, 5 );
function populate_complist($value, $form_id, $field_id, $entry, $column, $query_string){
//only populating drop down for form id 7 - if editing this change to your own form ID
if($form["id"] != 42 && $field_id != 1)
// This adds display names for all users to a drop down box on a gravity form.
add_filter("gform_pre_render", "populate_zone");
//Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displayed when editing the entry.
add_filter("gform_admin_pre_render", "populate_zone");
function populate_zone($form){
//only populating drop down for form id 9 - if editing this change to your own form ID
if($form["id"] != 7)
return $form;