Skip to content

Instantly share code, notes, and snippets.

@zackkatz
zackkatz / gravityview-gravity-flow-clear-cache.php
Last active Jul 29, 2020
GravityView - Clears results cache after running Gravity Flow workflow
View gravityview-gravity-flow-clear-cache.php
<?php
// Add the code below to your functions.php file. Will be included in GravityView 2.9 release.
add_action( 'gravityflow_post_process_workflow', 'gv_clear_cache_after_workflow', 10, 4 );
/**
* Clears GravityView entry cache after running a Gravity Flow Workflow
*
* Thanks to @CodenomadIndia for improved code!
@zackkatz
zackkatz / gravityview-anchor-after-search.php
Last active Jun 1, 2020
GravityView - How to navigate to an anchor after search
View gravityview-anchor-after-search.php
<?php
/**
* Modify the action of the Search Bar form to navigate to #site-content anchor after search
*
* @param string $url Where the form submits to.
*
* @returns string Modified URL with anchor added
*/
add_filter( 'gravityview/widget/search/form/action', function ( $url ) {
@zackkatz
zackkatz / gv-calendar-remove-time-display.php
Last active May 24, 2020 — forked from rafaehlers/gv_calendar_remove_time_display.php
Gravity Forms Calendar - Prevent time from being displayed in the calendar
View gv-calendar-remove-time-display.php
<?php // DO NOT COPY THIS LINE
/**
* Remove the time from being displayed on a GravityView calendar
*
* @see https://docs.gravityview.co/category/647-calendar
*
* @param array $calendar_options Array of FullCalendar options
*
* @return mixed
@zackkatz
zackkatz / gravityview-update-approval.php
Created Mar 17, 2020
GravityView - Update Entry Approval Status using PHP
View gravityview-update-approval.php
<?php
// Check to make sure GravityView is loaded
if ( ! class_exists( 'GravityView_Entry_Approval' ) ) {
return;
}
/**
* There are three options that should be used when updating entry approval statuses:
* GravityView_Entry_Approval_Status::APPROVED - Approved/Accepted entries
@zackkatz
zackkatz / gravityview-check-has-entry-revisions.php
Created Feb 27, 2020
GravityView Entry Revisions - How to check whether an entry is a revision
View gravityview-check-has-entry-revisions.php
<?php
$entry = GFAPI::get_entry( 1234 ); // Replace '1234' with your own Entry ID
if( 'gv-revision' === $entry['status'] ) {
// This entry is actually a revision!
}
@zackkatz
zackkatz / gravityview-calendar-modify-events.php
Last active Mar 28, 2020
GravityView Calendar - Modify the settings for a single event
View gravityview-calendar-modify-events.php
<?php
/**
* Modify event array that is output to FullCalendar
* In this sample code, we add a background color to a specific event
*
* @param array $events Array of events
* @param object $form Calendar form
* @param object $feed Calendar feed
* @param array $field_map Array of feed fields mapped to calendar settings (e.g., start_time, end_time)
@zackkatz
zackkatz / gravityview-show-checkbox-as-csv.php
Created Feb 25, 2020
GravityView - Display checkbox values as comma-separated instead of a bullet list
View gravityview-show-checkbox-as-csv.php
<?php
/**
* Convert checkbox <ul> to CSV values
*
* @param string $output The current output.
* @param \GV\Template_Context The template context this is being called from.
*/
add_filter( 'gravityview/template/field/checkbox/output', function( $output, $context ) {
@zackkatz
zackkatz / prevent-adding-revision.php
Last active Apr 14, 2020
Entry Revisions - Prevent adding revisions for a specific form
View prevent-adding-revision.php
<?php
/**
* Prevent adding revisions for a specific form
*
* @param bool $add_revision Should a revision be added?
* @param integer $entry_id The entry ID that was updated
* @param array $form The form object for the entry.
* @param array $original_entry The entry object before being updated
*
@zackkatz
zackkatz / gravityview-diy-remove-markup.php
Created Feb 4, 2020
Remove GravityView DIY Layout Markup
View gravityview-diy-remove-markup.php
<?php
// Remove wrapper HTML in Multiple Entries context
add_filter( 'gravityview-diy/wrap/multiple', '__return_false' );
// Remove .gv-diy-container container <div> for DIY
add_filter( 'gravityview-diy/container', '__return_empty_string' );
@zackkatz
zackkatz / datepicker-options-pre-init.php
Created Jan 28, 2020
GravityView - Modify Gravity Forms Date Picker Options Settings
View datepicker-options-pre-init.php
<?php
add_action( 'wp_head', function() {
?>
<script>
jQuery( document ).ready( function() {
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
console.log( 'gform_datepicker_options_pre_init: ' + formId + ' ' + fieldId );
console.log( optionsObj );
return optionsObj;