Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter( 'gravityview_entries', function( $entries, $criteria, $passed_criteria, &$total ) {
$view_id = GravityView_frontend::getInstance()->get_context_view_id();
if ( $view_id != 97 /** Augmented View ID here */ ) {
return $entries;
}
$_subtract = $criteria;
@zackkatz
zackkatz / add-gf-to-admin-dashboard.php
Last active May 2, 2018 03:08 — forked from lukecav/functions.php
Add Gravity Forms to the Wordpress Dashboard as a Widget
<?php
add_action( 'wp_dashboard_setup', 'add_gf_to_dashboard_setup' );
function add_gf_to_dashboard_setup() {
wp_add_dashboard_widget( 'wp_gf_dashboard', 'My Gravity Form', 'add_gf_to_dashboard' );
}
function add_gf_to_dashboard() {
@zackkatz
zackkatz / gravityview-modify-custom-content.php
Last active May 17, 2018 19:05 — forked from luistinygod/gist:9dce30ca1fd146dd31bc
GravityView - Modify the content returned from the Custom Content field
<?php
/** Modify the content returned from the Custom Content field */
add_filter( 'gravityview/fields/custom/content_before', 'my_gv_custom_content_before', 10, 2 );
/**
* Removes the custom content field's content in case a certain entry field is empty
* Replace the MY_FIELD_ID by the field id (check it on the Gravity Forms form definition)
*
* @param string $content Custom Content field content
* @param \GV\Template_Context $context
@zackkatz
zackkatz / gravityview-calculations-in-custom-content-field.php
Last active May 17, 2018 22:30 — forked from luistinygod/gist:7594392d3a474cf93df0
GravityView: Show the result of a calculation using a Custom Content field
<?php
/**
* Referenced in this article: http://docs.gravityview.co/article/235-how-to-make-calculations-using-the-custom-content-field
*/
/** Modify the content returned from the Custom Content field */
add_filter( 'gravityview/fields/custom/content_before', 'my_gv_custom_content_before', 10, 2 );
/**
* Replaces the %CALC% placeholder by the result of a calc operation between entries' fields
@zackkatz
zackkatz / gv_age.php
Last active May 21, 2018 20:01 — forked from rafaehlers/gv_age.php
GravityView - Calculate a person's age based on a date field
<?php
add_shortcode( 'gv_age', 'gv_calculate_age' );
/**
* Calculate age in years based on entry data
*
* Usage inside a Custom Content field (Replace "2" with the ID of the date field):
*
* <code>
<?php
/**
* Place this in your theme's functions.php
* Please adapt the form_id and the field key to your own case.
* This is intended to force GravityView to search for the exact value instead of be more relaxed (default search uses operator LIKE)
*
*/
add_filter( 'gravityview_fe_search_criteria', 'my_gv_exact_search', 20, 2 );
@zackkatz
zackkatz / maps-coordinates.php
Last active March 28, 2020 05:28 — forked from rafaehlers/maps-coordinates.php
Use the cordinates (Latitude and Longitude) instead of the address to position the markers over the Maps
<?php
/**
* Use the coordinates (Latitude, Longitude) instead of the address to position the markers over the Maps
*
* Replace 'MY_LATITUDE_FIELD_ID', 'MY_LONGITUDE_FIELD_ID' with field ids containing the latitude and longitude values
*
* @param array $fields_array Gravity Forms fields IDs containing the latitude and longitude
* @param GravityView_View $gravityview_view Current View object
*
* @return array Array with field IDs of latitude and longitude fields (Example: [ 5, 6 ] ). Empty array if not the form we want to override.
@zackkatz
zackkatz / gv-calendar-remove-time-display.php
Last active May 24, 2020 20:35 — forked from rafaehlers/gv_calendar_remove_time_display.php
Gravity Forms Calendar - Prevent time from being displayed in the calendar
<?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
<?php
$entries_url = 'https://try.gravityview.co/demo/wp-json/gravityview/v1/views/148/entries.json';
$nonce = wp_create_nonce( 'wp_rest' );
?>
<script type="text/javascript">
jQuery.ajax( {
url: <?php echo json_encode( $entries_url ); ?>,
method: 'GET',
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', <?php echo json_encode( $nonce ); ?> );
@zackkatz
zackkatz / gv-change-back-link.php
Last active January 4, 2022 21:00 — forked from rafaehlers/gv-change-back-link.php
GravityView - Change the back link URL for a specific View ID