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 / php
Created Sep 23, 2014
GF Entry Manipulation
View php
<?php
add_filter("gform_after_submission", "post_form_anonymize", 10 , 2);
//Gravity Form Submission
function post_form_anonymize($entry, $form){
$cssClasses = preg_split('/[\ \n\,]+/', $form['cssClass']);
if (in_array("anonymize", $cssClasses)) {
RGFormsModel::update_lead_property($entry['id'], "created_by","1");
RGFormsModel::update_lead_property($entry['id'], "ip","XXX.YYY.XXX.YYY");
@Idealien
Idealien / gflow-complete-step-function.php
Last active Mar 29, 2018
Gravity Flow - Different ways to have workflow step(s) trigger post status update
View gflow-complete-step-function.php
//Update after each step completion - probably executes too often for most use cases
add_action( 'gravityflow_step_complete', 'gravityflow_step_complete_post_publish', 10, 4 );
function gravityflow_step_complete_post_publish( $step_id, $entry_id, $form_id, $status ) {
$entry = GFAPI::get_entry( $entry_id );
$currentPost = get_post( rgar( $entry, 'post_id' ) );
if("draft" == $currentPost->post_status) {
@Idealien
Idealien / functions.php
Last active Dec 11, 2017
Gravity Forms - Tally Common Questions in Merge Tag
View functions.php
<?php
add_filter( 'gform_replace_merge_tags', array(&$this, "replace_tally_results"), 10, 7 );
function replace_tally_results( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
$custom_merge_tag = '{tally_results}';
if ( strpos( $text, $custom_merge_tag ) === false ) {
return $text;
}
$score = array();
foreach($form['fields'] as $field) {
@Idealien
Idealien / wpallimport - functions.php
Created May 19, 2016
WP All Import - Users - Maintain multiple roles in wp_capabilities user meta
View wpallimport - functions.php
<?php
function ipost_import_roles($employee_ID) {
$user_query = new WP_User_Query( array( 'meta_key' => 'employee_id', 'meta_value' => $employee_ID ) );
$defaultRole = array("employee" => true);
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
if( $user->roles ) {
$roles = $defaultRole;
foreach( $user->roles as $role ) {
@Idealien
Idealien / step3A-functions.php
Last active Dec 11, 2017
ACF + Rest API = Powerful!
View step3A-functions.php
<?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;
View ACF-conditional-display-for-non-select-fields.js
(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 / bash.sh
Created Oct 31, 2016
WP Gravity Forms CLI - Entry Generation for Workflows
View bash.sh
#!/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)
@Idealien
Idealien / functions.php
Created Nov 2, 2016
WP Gravity Flow Bulk Creation for Import Plugin Processing
View functions.php
<?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;
View game_customize_core_example.php
<?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,
You can’t perform that action at this time.