Skip to content

Instantly share code, notes, and snippets.

@Idealien
Idealien / functions.php
Created May 7, 2018 10:57
Gravity Flow - User Input Validation to prevent step completion without certain data
<?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 September 11, 2018 00:51
Core pieces to get assignee info into Gravity Flow status
<?php
add_filter( 'gravityflow_columns_status_table', 'custom_column_titles', 10, 3 );
function custom_column_titles( $columns, $args, $table ) {
$new_column = array(
'assignees' => 'Assignee(s)',
);
$pre_columns = array_slice( $columns, 0, 2 );
$post_columns = array_slice( $columns, 2 );
$columns = array_merge( $pre_columns, $new_column, $post_columns );
@Idealien
Idealien / php
Created September 23, 2014 03:16
GF Entry Manipulation
<?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 / 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 18, 2020 02:18
Disable TinyMCE for a specific step settings editor
add_action( 'admin_init', 'disable_tinymce_in_gf' );
function disable_tinymce_in_gf() {
if (rgget('fid')){
$step_id = rgget('fid');
if ($step_id == 552) {
if ( RGForms::is_gravity_page() &&
rgget( 'page' ) == 'gf_edit_forms' &&
rgget( 'view' ) == 'settings' &&
in_array( rgget( 'subview' ), array( 'notification', 'confirmation', 'gravityflow' ) )
) {
@Idealien
Idealien / functions.php
Created October 5, 2019 16:55
Gravity Flow - Assignee Field based access control via summary shortcode
<?php
add_filter( 'gravityflow_search_criteria_status', 'jo_status_scenario_search_criteria', 10, 1 );
function jo_status_scenario_search_criteria( $search_criteria ) {
if ( ! isset( $_SERVER['REQUEST_URI'] ) && strpos( strtolower( $_SERVER['REQUEST_URI'] ), '/status-check-64/' ) !== false ) {
return $search_criteria;
}
$current_user = wp_get_current_user();
@Idealien
Idealien / majorupdates.drama
Last active August 9, 2019 20:48
wp.drama
• Changing running websites without the consent of their owners is just like putting your hand on the oven.
• Are you suggesting forced auto-updates to newer major versions? If so, then I think you’re setting yourself up for disaster.
• What happens if the outage causes financial issues to the owner?
• I would propose to drop this idea completely, for lack of realism.
• In the area of small businesses losing contact to the admin happens regularly, either because of distrust or because of the admin changing his professional focus or lack of money. This plan will put all of those site owners at risk, and more of them with every step up the update ladder.
• Put an alarm system into the next minor.
• Absence of an answer does not indicate consent.
• In reality, choices are never between a purely good thing and a purely bad thing; they’re always between competing tradeoffs.
• If you think that I’m going to miss even one opportunity to pick up half-a-knot boat speed, you’re absolutely out of your mind. When it cost
@Idealien
Idealien / install.sh
Created December 6, 2018 00:05 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@Idealien
Idealien / functions.php
Created September 27, 2018 23:48
Remove a Gravity Form entry immediately after submission
<?php
add_action( 'gform_after_submission_3', 'remove_entry_magic', 10, 2);
function remove_entry_magic( $entry ) {
GFAPI::delete_entry( $entry['id'] );
}
(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) {