Skip to content

Instantly share code, notes, and snippets.

@altoin
altoin / lookupformat.php
Created August 28, 2024 06:58
Change the return format for date and time in lookup field.
<?php
add_filter( 'frm_filtered_lookup_options', 'format_date_display', 10, 2 );
function format_date_display( $options, $args ) {
if ( $args['field']->id == 31427 ) { // change 20116 to the ID of the date field in the other form
foreach ( $options as $k => $option ) {
$option =new DateTime($option);
$options[$k]= date_format($option,"m/d/Y");;
}
}
@altoin
altoin / gv-no-entries-view-specific.php
Created February 15, 2019 18:53
Display a custom message when no entries are returned, for a specific View ID
<?php //MAKE SURE TO REMOVE THIS WHOLE LINE FIRST
add_filter( 'gravityview/template/text/no_entries', 'modify_gravityview_no_entries_text', 10, 3 );
function modify_gravityview_no_entries_text( $existing_text, $is_search = false, $context = null ) {
$view_id = $context->view->ID;
if($view_id == 8) //Change this number to your View ID
{
if( $is_search ) {
$return = 'Your search came up empty! [Use your own new search text]';
} else {
$return = "There just aren't any results! [Use your own text]";
@altoin
altoin / GravityView Entry Slug Filter
Created January 30, 2019 19:54
Change default entry ID to your custom slug
<?php
add_filter('gravityview_entry_slug', 'change_the_gravityview_entry_slug');
/**
* Change the /123/ URL piece to /myslug/
* @param string $slug Previous slug, default: "entryId"
* @return string Change the new endpoint to "myslug"
*/
function change_the_gravityview_entry_slug( $slug ) {
return 'myslug';
}
@altoin
altoin / gv_datatables_csv_filename_rename.php
Last active January 8, 2019 18:05
Rename filename when exporting CSV/ Excel using DataTables extensions in GravityView
<?php
/* Rename the CSV filename.*/
add_filter('gravityview/datatables/button_csv','gravityview_csv_export_settings', 10 ,2);
function gravityview_csv_export_settings( $button_config = array(), $view_id){
if($view_id==19)/* You must pass a Valid View ID here for this to work*/
{
$button_config['filename'] = 'my_csv'; /*please change 'my_csv' to your preffered filename*/
return $button_config;
}