Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter('gravityflow_inbox_args', 'registrations_inbox_form_ids', 10, 1);
function registrations_inbox_form_ids( $args ) {
//Specify which instance of the shortcode you want to affect
if( false !== strpos($args['detail_base_url'], '/event-registrations/') ) {
$registrations = array( '106, '107');
@Idealien
Idealien / gist.php
Created January 12, 2018 02:09
Gravity Flow Timeline Manipulation
<?php
$API = new Gravity_Flow_API( '1' );
$form = GFAPI::get_form( '1' );
require_once( gravity_flow()->get_base_path() . '/includes/pages/class-entry-detail.php' );
$notes = Gravity_Flow_Entry_Detail::get_timeline_notes( $entry );
$output = "<H3>Timeline</h3><ul>";
foreach( $notes as $note):
if( $note->user_name !== 'notification' && $note->value !== 'Step expired' ):
@Idealien
Idealien / functions.php
Created January 28, 2018 22:09
GFlow - Specific User Assignment
<?php
add_filter( "gravityflow_user_field", "gflow_request_manager", 10, 3 );
function gflow_request_manager( $choices, $form_id, $field ) {
if ( $form_id == 1 && $field->id == 15 ) {
$manager = get_user_by('email', get_user_meta(get_current_user_id(), "manager_email", true) );
if( false !== $manager ) {
$choices = array(
array('value' => $manager->ID, 'text' => $manager->first_name . ' ' . $manager->last_name)
@Idealien
Idealien / functions.php
Created February 2, 2018 20:57
Gravity Flow - Step Assignee - Bypass "re-assignment" with email change
<?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 ) {
@Idealien
Idealien / functions.php
Created February 5, 2018 11:37
Gravity Flow - Conclude Workflow as Complete
<?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
Last active March 28, 2020 04:48
Preliminary Business Hour Notification Example
<?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 February 12, 2018 17:55
Gravity Forms Web API v2 - /form/##/entries/ - Authorisation by Form ID
<?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 / gf-confirm.js
Created February 17, 2018 04:05
Gravity Flow - Confirmation dialog before form submit
(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 February 20, 2018 00:09
Gravity Flow Status Column with Step Time
<?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 / functions.php
Created February 20, 2018 00:16
Gravity Forms - Custom Export Column
<?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 ) {