Skip to content

Instantly share code, notes, and snippets.

@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 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 / 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' ):
<?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 / screenshot_checkbox.jpg
Last active March 25, 2017 18:23
Images for CMB2
screenshot_checkbox.jpg
<?php
add_action( 'rest_api_init', 'rest_register_game_meta' );
function rest_register_game_meta() {
//For generic fields that should never allow front-end updates
$restArgsDisplay = array(
'get_callback' => 'rest_get_game_meta',
'update_callback' => null,
'schema' => null,
@Idealien
Idealien / functions.php
Created November 2, 2016 23:54
WP Gravity Flow Bulk Creation for Import Plugin Processing
<?php
//replace ## with your form ID - and also update field IDs with your appropriate numbers.
add_action( "gform_pre_submission_##", "employee_lookup_and_assignment", 10, 1 );
function employee_lookup_and_assignment( $form ) {
$reviewer = get_user_by( 'email', rgpost( 'input_12' ));
if( $reviewer ):
$_POST['input_10'] = "user_id|" . $reviewer->ID;
endif;
@Idealien
Idealien / bash.sh
Created October 31, 2016 21:56
WP Gravity Forms CLI - Entry Generation for Workflows
#!/bin/bash
INPUT=input_filename.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read reviewer employee
do
f10=$(wp user get $reviewer --field=ID)
f11=$(wp user get $employee --field=ID)
f14=$(wp user meta get $employee user_meta_field_name)
(function($) {
acf.add_action('ready', function( $el ){
//Identify the field you want to check against.
//Use a class to handle scenarios involving repeater / flexible content where multiple instances exist
var $field = $('.example input');
$field.on('change', function (evt) {
@Idealien
Idealien / step3A-functions.php
Last active December 11, 2017 08:09
ACF + Rest API = Powerful!
<?php
//REST API - Enable more fields to be searched via Rest API
add_filter( 'rest_query_vars', function ( $valid_vars ) {
$update_vars = $valid_vars;
//Vehicle Meta Data
$update_vars = array_merge( $update_vars, array( 'make', 'meta_query' ) );
$update_vars = array_merge( $update_vars, array( 'model', 'meta_query' ) );
return $update_vars;