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-highlight-row.php
Last active May 12, 2021 20:25
Highlight an entire row if entry is approved
<?php // DO NOT COPY THIS LINE
// https://github.com/gravityview/GravityView/issues/1315
add_filter( 'gravityview/template/table/entry/class', function( $class, $context ) {
$view_id = $context->view->ID;
if($view_id == 8){
if ( $context->entry['is_approved'] == 1 ) {
<?php // DO NOT COPY THIS LINE
// Merge Tag Modifier to pull only the first character of a string. Usage {Field:1:firstword} inside a custom content field
add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value ) {
if( 'all_fields' !== $merge_tag && 'firstword' === $modifier ) {
$value = force_balance_tags( wp_specialchars_decode( substr( htmlentities( $value ), 0, 1 ) ) );
@rafaehlers
rafaehlers / gv-validate_entry_before_creation.php
Created March 2, 2021 03:15
validate_entry_before_creation
<?php
add_filter( 'gform_validation', 'validate_entry_before_creation', 100 );
function validate_entry_before_creation( $data ) {
foreach ( $data['form']['fields'] as $field ) {
if ( $field->id !== 1 ) { // replace 1 with the unique field ID
continue;
}
$unique_id = RGFormsModel::get_field_value( $field );
// check if entry exists based on the $unique_id (e.g., passing it to https://docs.gravityforms.com/api-functions/#get-entries)
@rafaehlers
rafaehlers / gv-dt-clear-sort.php
Created December 22, 2020 18:07
Prevent DataTables from saving the sort information on the Browser's storage
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview_datatables_js_options', function( $dt_config, $view_id, $post ) {
$dt_config['order'] = array();
$dt_config['stateSave'] = false;
return $dt_config;
}, 10, 3 );
@rafaehlers
rafaehlers / gv-rename-update-cancel.php
Last active November 4, 2020 08:55
Rename the Update and Delete buttons on the Edit Entry page
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/edit_entry/button_labels', 'gv_modify_edit_entry_buttons', 10, 4 );
function gv_modify_edit_entry_buttons( $labels, $form, $entry, $view_id ){
$labels = array(
'cancel' => __( 'Cancel Update', 'gravityview' ),
'submit' => __( 'Update Entry', 'gravityview'),
'next' => __( 'Next page', 'gravityview'), // for multi-page forms
'previous' => __( 'Previous page', 'gravityview') // for multi-page forms
@rafaehlers
rafaehlers / gravityview-hide-approve-column-per-form.php
Created June 11, 2020 01:53
GravityView - Override whether the Approve/Reject Entry column is shown
<?php
/**
* Override whether the Approve/Reject Entry column is shown, per form
* Requires GravityView 1.7.2
*
* @param boolean $show_approve_column Whether the column will be shown
* @param int $form_id The ID of the Gravity Forms form for which entries are being shown
*
* @return boolean
<?php
existing code
<?php // <--- This is a duplicate tag.
new code you pasted
?>
@rafaehlers
rafaehlers / gv_calendar_remove_time_display.php
Created March 27, 2020 23:23
// GravityView Calendar add-on - Prevent time from being displayed in the Calendar
<?php // DO NOT COPY THIS LINE
function gv_calendar_remove_time_display( $calendar_options ){
$calendar_options['displayEventTime'] = false; // Disable displaying of time
return $calendar_options;
}
add_filter('gravityview/calendar/options', 'gv_calendar_remove_time_display', 10, 1);
@rafaehlers
rafaehlers / gv-remote-entry-approval-notes.php
Last active March 10, 2023 19:56
Prevent Entry Approval Notes from displaying on the View
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/entry_notes/get_notes', 'gv_remove_entry_approval_notes', 10, 2 );
function gv_remove_entry_approval_notes( $notes, $entry_id ) {
foreach($notes as $key => $note){
if (strpos( $note->value, 'WordPress') !== false){
unset( $notes[ $key] );
}
}
return $notes;
@rafaehlers
rafaehlers / gv-remove-gravityflow-notes.php
Created March 11, 2020 04:22
Prevent Gravity Flow notes from appearing on the View
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/entry_notes/get_notes', 'gv_remove_gravityflow_notes', 10, 2 );
function gv_remove_gravityflow_notes( $notes, $entry_id ) {
foreach($notes as $key => $note){
if ($note->note_type === 'gravityflow'){
unset( $notes[ $key] );
}
}
return $notes;