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");
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,
@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;
@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 / 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 / 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
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 / 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 ) {
You can’t perform that action at this time.