Skip to content

Instantly share code, notes, and snippets.

View rafaehlers's full-sized avatar

Rafael M. Ehlers rafaehlers

View GitHub Profile
@rafaehlers
rafaehlers / gv-edit-trigger-paypal-feed.php
Last active February 6, 2025 17:34
Trigger a PayPal add-on feed after editing an entry
<?php // DO NOT COPY THIS LINE
add_action( 'gravityview/edit_entry/after_update', 'gravityview_trigger_paypal_feeds', 10, 3 );
function gravityview_trigger_paypal_feeds( $form = array(), $entry_id = array(), $object ) {
if ( 100 !== (int) $form['id'] ) { // replace 100 with your form ID
return;
}
@rafaehlers
rafaehlers / gv-remove-lightbox-pdf.php
Last active January 17, 2022 19:52
Remove Lightbox from PDFs
<?php
add_filter('gravityview/fields/fileupload/files_array', 'gv_modify_files_output_pdf',10,1);
function gv_modify_files_output_pdf($output_arr){
foreach ($output_arr as $key => $value) {
$pdf_exists = strpos($value['file_path'], '.pdf');
if ($pdf_exists !== false) {
$gf_download = strpos($value['file_path'],'?gf-download=');
if ($gf_download == false) {
$gravity_forms = strpos($value['file_path'],'/gravity_forms/');
<?php
add_filter( 'gv_ratings_reviews_review_form_settings', 'gv_modify_review_form_labels',10,1);
function gv_modify_review_form_labels($defaults){
$view_id = GravityView_View::getInstance()->getViewId();
if($view_id == 30){
$new_defaults = array(
'title_reply' => 'Review Team Member',
);
@rafaehlers
rafaehlers / gv-remove-other-from-search-bar-dropdowns.php
Created January 7, 2022 22:16
If there's an "Other" choice on a dropdown field inside a Search Bar, remove it.
<?php // DO NOT COPY THIS LINE
add_action( 'gravityview_search_widget_fields_before', 'gv_modify_search_fields', 10);
function gv_modify_search_fields( $search_obj ){
foreach( $search_obj->search_fields as $key => &$search_field ) {
if ( $search_field['type'] === 'select' ){
foreach ( $search_field['choices'] as $key => $value ){
@rafaehlers
rafaehlers / gf-calendar-events.php
Last active March 10, 2022 22:15
Modify event colors based on a field value
<?php // DO NOT COPY THIS LINE
/**
* 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).
* @param array $entries Array of entries being displayed in the calendar (Requires 1.5.2)
@rafaehlers
rafaehlers / gv-expiration.php
Created June 18, 2021 20:05
Shortcode that receives a date field and calculates it with another date using relative dates
<?php // DO NOT COPY THIS LINE
//USAGE: [gv_expiration date="2" duration="+1 year"]
// 2 is the field ID of the date field
// If original date is "2021-04-01" it will output "2022-04-01"
// https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates
add_shortcode( 'gv_expiration', 'gv_expiration' );
function gv_expiration( $atts ) {
global $gravityview_view;
@rafaehlers
rafaehlers / gravityview_trigger_all_form_feeds.php
Created June 7, 2021 22:20
Trigger all feeds on your form when editing an entry in GravityView
<?php // DO NOT COPY THIS LINE
add_action( 'gravityview/edit_entry/after_update', 'gravityview_trigger_feeds', 10, 3 );
function gravityview_trigger_feeds( $form = array(), $entry_id = array(), $object ) {
if ( 100 !== (int) $form['id'] ) { // replace 100 with your form ID
return;
}
@rafaehlers
rafaehlers / gravityview_trigger_webhooks_feed.php
Created June 3, 2021 18:45
Trigger WebHook feeds on your form when editing an entry in GravityView
<?php // DO NOT COPY THIS LINE
add_action( 'gravityview/edit_entry/after_update', 'gravityview_trigger_webhooks_feed', 10, 3 );
function gravityview_trigger_webhooks_feed( $form = array(), $entry_id = array(), $object ) {
if ( 100 !== (int) $form['id'] ) { // replace 100 with your form ID
return;
}
@rafaehlers
rafaehlers / gravityview_trigger_zapier_feed.php
Created June 3, 2021 18:43
Trigger Zapier feeds on your form when editing an entry in GravityView
<?php // DO NOT COPY THIS LINE
add_action( 'gravityview/edit_entry/after_update', 'gravityview_trigger_zapier_feed', 10, 3 );
function gravityview_trigger_zapier_feed( $form = array(), $entry_id = array(), $object ) {
if ( 100 !== (int) $form['id'] ) { // replace 100 with your form ID
return;
}
@rafaehlers
rafaehlers / gv-highlight-row-field.php
Last active March 4, 2022 20:44
Highlight an entire row if field condition is met (only works with Table View)
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/template/table/entry/class', function( $class, $context ) {
$view_id = $context->view->ID;
if($view_id == 46){ // Modify to target only View with specific ID (46 in this case)
if ( $context->entry[1] == '1' ) {
$class .= ' highlight-yes'; // If field ID 1's value is equal to 1 then add the CSS class