Skip to content

Instantly share code, notes, and snippets.

Jamie O Idealien

Block or report user

Report or block Idealien

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Idealien
Idealien / functions.php
Created May 7, 2018
Gravity Flow - User Input Validation to prevent step completion without certain data
View functions.php
<?php
add_filter( 'gravityflow_validation_user_input', 'step_complete_data_check', 10, 3 );
add_filter( 'gravityflow_validation_user_input', 'step_inprogress_bypass_required', 10, 3 );
function step_complete_data_check( $validation_result, $step, $new_status ) {
if( ($validation_result['form']['id'] == "121" && rgpost( 'step_id' ) == 40 && $new_status == 'in_progress') ) {
foreach( $form['fields'] as &$field ) {
@Idealien
Idealien / functions.php
Created Mar 17, 2018
Gravity Flow - Custom Column for status table based on creator, assignee, etc
View functions.php
<?php
add_filter( 'gravityflow_columns_status_table', 'custom_column_titles', 10, 3 );
function custom_column_titles( $columns, $args, $table ) {
$new_column = array(
'user_action' => 'User Action',
);
$pre_columns = array_slice( $columns, 0, 2 );
$post_columns = array_slice( $columns, 2 );
$columns = array_merge( $pre_columns, $new_column, $post_columns );
return $columns;
@Idealien
Idealien / functions.php
Created Mar 2, 2018
Gravity Flow - Adjust Discussion Display Limit
View functions.php
<?php
add_filter( 'gravityflow_discussion_items_display_limit', 'limit_discussion_display', 10, 2 );
function limit_discussion_display( $display_limit, $discussion_field ) {
//Change to control which form / field the limit change is applied to
if ( $discussion_field['formId'] == '25' ) {
$display_limit = 2;
}
return $display_limit;
}
@Idealien
Idealien / functions.php
Created Feb 20, 2018
Gravity Forms - Custom Export Column
View functions.php
<?php
add_filter( 'gform_export_fields', 'add_step_updated', 10, 1 );
function add_step_updated( $form ) {
array_push( $form['fields'], array( 'id' => 'step_updated', 'label' => __( 'Step Last Updated', 'gravityforms' ) ) );
return $form;
}
add_filter( 'gform_export_field_value', 'set_step_updated', 10, 4 );
function set_step_updated( $value, $form_id, $field_id, $entry ) {
switch ( $field_id ) {
@Idealien
Idealien / functions.php
Created Feb 20, 2018
Gravity Flow Status Column with Step Time
View functions.php
<?php
add_filter( 'gravityflow_columns_status_table', 'custom_column_titles', 10, 3 );
function custom_column_titles( $columns, $args, $table ) {
$columns['last_updated'] = 'Last Updated';
return $columns;
}
add_filter( 'gravityflow_field_value_status_table', 'custom_column_field_values', 10, 4 );
function custom_column_field_values( $value, $form_id, $column_name, $entry ) {
@Idealien
Idealien / gf-confirm.js
Created Feb 17, 2018
Gravity Flow - Confirmation dialog before form submit
View gf-confirm.js
(function (GravityFlowEntryDetail, $) {
$(document).ready(function () {
if( $('.gravityflow-step-user_input').length ) {
//User Input - Save Progress Button
if( $('#gravityflow_save_progress_button').length ) {
$('#gravityflow_save_progress_button')[0].onclick = null;
$('#gravityflow_save_progress_button').click(function() {
$('#action').val('update');
@Idealien
Idealien / functions.php
Created Feb 12, 2018
Gravity Forms Web API v2 - /form/##/entries/ - Authorisation by Form ID
View functions.php
<?php
add_filter( "gform_rest_api_capability_get_entries", "gfapi2_authorization_by_form", 10, 2);
function gfapi2_authorization_by_form( $capability, $request ) {
$form_id = $request->get_param("form_id");
if( $form_id == '16' ) {
$capability = 'read';
}
return $capability;
}
@Idealien
Idealien / functions.php
Last active Mar 29, 2018
Preliminary Business Hour Notification Example
View functions.php
<?php
add_filter( 'gravityflow_step_schedule_timestamp', 'schedule_business_hours', 10, 3 );
function schedule_business_hours( $schedule_timestamp, $schedule_type, $step ) {
//Ensure you are only adjusting the desired form/step
if ( $step->get_id() !== 74 ) {
return $schedule_timestamp;
}
gravity_flow()->log_debug( __METHOD__ . '(): Original Scheduled: ' . date( 'Y-m-d H:i:s', $schedule_timestamp ) );
@Idealien
Idealien / functions.php
Created Feb 5, 2018
Gravity Flow - Conclude Workflow as Complete
View functions.php
<?php
add_action( 'gravityflow_workflow_complete', 'workflow_finish_complete_status', 5, 3 );
function workflow_finish_complete_status( $entry_id, $form, $final_status ) {
if ( $form['id'] == '31' ) {
if ( $final_status == 'approved' ) {
$entry = GFAPI::get_entry( $entry_id );
if ( $entry ) {
$entry['workflow_final_status'] = 'complete';
$result = GFAPI::update_entry( $entry );
@Idealien
Idealien / functions.php
Created Feb 2, 2018
Gravity Flow - Step Assignee - Bypass "re-assignment" with email change
View functions.php
<?php
add_filter( 'gravityflow_step_assignees', 'bypass_step_assignee_on_email_change', 10, 2 );
function bypass_step_assignee_on_email_change( $assignees, $step ) {
//Update with the ID of your specific step to apply the bypass against
if ( $step->get_id() == '76' ) {
if ( isset( $_POST['gforms_save_entry'] ) && count( $_POST ) > 0 ) {
$reset = false;
if ( $assignees ) {
foreach ( $assignees as $key => $assignee ) {
You can’t perform that action at this time.