Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logging statements for Gravity Forms.
<?php
add_filter( 'gform_pre_render', 'log_pre_render' );
function log_pre_render( $form ) {
GFCommon::log_debug( "log_pre_render(): \$form => " . print_r( $form, true ) );
return $form;
}
add_action( 'gform_pre_process', 'log_pre_process' );
function log_pre_process( $form ) {
//GFCommon::log_debug( "log_pre_process(): \$form => " . print_r( $form, true ) );
GFCommon::log_debug( "log_pre_process(): \$_POST => " . print_r( $_POST, true ) );
}
add_filter( 'gform_validation', 'log_validation_failure' );
function log_validation_failure( $validation_result ) {
$form = $validation_result["form"];
foreach( $form["fields"] as &$field ) {
if( $field["failed_validation"] )
GFCommon::log_error( "form #{$form["id"]}: validate() - failed: {$field["label"]}({$field["id"]} - {$field["type"]}) - message: {$field["validation_message"]}" );
}
return $validation_result;
}
add_action( 'gform_pre_submission', 'log_pre_submission' );
function log_pre_submission( $form ) {
//GFCommon::log_debug( "log_pre_submission(): \$form => " . print_r( $form, true ) );
GFCommon::log_debug( "log_pre_submission(): \$_POST => " . print_r( $_POST, true ) );
}
add_filter( 'gform_save_field_value', 'log_save_field_value', 10, 4 );
function log_save_field_value( $value, $lead, $field, $form ) {
GFCommon::log_debug( "log_save_field_value(): \$value => " . print_r( $value, true ) );
return $value;
}
add_filter( 'gform_notification', 'log_notification', 10, 3 );
function log_notification( $notification, $form, $entry ) {
GFCommon::log_debug( "log_notification(): \$notification => " . print_r( $notification, true ) );
//GFCommon::log_debug( "log_notification(): \$form => " . print_r( $form, true ) );
//GFCommon::log_debug( "log_notification(): \$entry => " . print_r( $entry, true ) );
return $notification;
}
add_filter( 'gform_confirmation', 'log_confirmation', 10, 4 );
function log_confirmation( $confirmation, $form, $lead, $ajax ) {
GFCommon::log_debug( "log_confirmation(): \$confirmation => " . print_r( $confirmation, true ) );
//GFCommon::log_debug( "log_confirmation(): \$form => " . print_r( $form, true ) );
//GFCommon::log_debug( "log_confirmation(): \$lead => " . print_r( $lead, true ) );
//GFCommon::log_debug( "log_confirmation(): \$ajax => " . print_r( $ajax, true ) );
return $confirmation;
}
add_action( 'gform_after_submission', 'log_after_submission', 10, 2 );
function log_after_submission( $entry, $form ) {
GFCommon::log_debug( "log_after_submission(): \$entry => " . print_r( $entry, true ) );
//GFCommon::log_debug( "log_after_submission(): \$form => " . print_r( $form, true ) );
}
add_action( 'gform_entry_info', 'log_entry_info', 10, 2 );
function log_entry_info( $form_id, $entry ) {
GFCommon::log_debug( "log_entry_info(): \$entry => " . print_r( $entry, true ) );
}
add_filter( 'gform_upload_path', 'log_upload_path', 10, 2 );
function log_upload_path( $path_info, $form_id ) {
GFCommon::log_debug( "log_upload_path(): \$path_info => " . print_r( $path_info, true ) );
return $path_info;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.