Usage
cf7_debug_info($cf7_instance)
Parameters
$cf7_instance
(Required) (Object) An instance of the CF7 form submission
Default: None
Parameter Notes
Use WPCF7_Submission::get_instance(); as the $cf7_instance parameter.
However, in most cases, child theme developers would interface with this function via the nebula_cf7_debug_info filter.
Examples
Get an array of debug info
$nebula_debug_info = nebula()->cf7_debug_info(WPCF7_Submission::get_instance());
Add custom data to the debug information
add_filter('nebula_cf7_debug_info', function($debug_info){
//Add custom data to the debug info
if ( get_option('tier_name') ){
$debug_info['tier'] = get_option('tier_name'); //Add an example item
}
return $debug_info; //Always return in filters!
});
Remove data from the debug information
add_filter('nebula_cf7_debug_info', function($debug_info){
unset($debug_info['nebula_anonymized_ip']); //Remove this item
return $debug_info; //Always return in filters!
});
Additional Notes
This debug info is sent to the recipient of the form if the shortcode [debuginfo] appears in the message of the Contact Form 7 form settings.
This debug info is stored in WordPress within the Nebula CF7 Submissions custom post type (which appears within the “Contact” admin menu item). It may appear in other form storage systems like the Advanced CF7 DB plugin, but mileage may vary.
Source File
Located in /libs/Functions.php on line 3488.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"nebula_cf7_debug_info"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one? public function cf7_debug_info($submission, $submission_data=false){
if ( $this->is_minimal_mode() ){return null;}
global $wp_version;
$debug_info = array();
$debug_info['wp_core_version'] = $wp_version;
$debug_info['nebula_timestamp'] = date('U');
$debug_info['nebula_date_formatted'] = date('l, F j, Y \a\t g:ia');
$debug_info['nebula_version'] = $this->version('full') . ' (Committed ' . $this->version('date') . ')';
$debug_info['nebula_child_version'] = $this->child_version('full');
$debug_info['nebula_session_id'] = sanitize_text_field($this->nebula_session_id());
$debug_info['nebula_ga_cid'] = sanitize_text_field($this->ga_parse_cookie());
//Try to detect the current page the form was submitted on
$current_page_url = '';
$current_page_method = '';
if ( !empty($submission_data) && isset($submission_data['_wpcf7_container_post']) ){
$current_page_url = get_permalink($submission_data['_wpcf7_container_post']);
$current_page_method = 'via CF7 container post submission data';
}
if ( empty($current_page_url) && !empty($submission) && is_object($submission) ){
$current_page_url = esc_url_raw($submission->get_meta('url'));
$current_page_method = 'via CF7 submission object';
}
if ( empty($current_page_url) && !empty(get_the_ID()) ){
$current_page_url = get_permalink(get_the_ID());
$current_page_method = 'via WP Post ID';
}
if ( empty($current_page_url) && get_queried_object_id() ){
$current_page_url = get_permalink(get_queried_object_id());
$current_page_method = 'via WP queried object ID';
}
$debug_info['nebula_current_page_url'] = sanitize_text_field($current_page_url);
$debug_info['nebula_current_page_method'] = sanitize_text_field($current_page_method);
$session_cookie_data = json_decode(stripslashes($this->super->cookie['session']), true);
if ( isset($session_cookie_data['landing_page']) ){
$debug_info['nebula_referrer'] = sanitize_text_field($session_cookie_data['referrer']); //This is the original referrer (not just the previous page)
$debug_info['nebula_landing_page'] = sanitize_text_field($session_cookie_data['landing_page']); //This is the first page view of the session
}
if ( $this->get_option('attribution_tracking') ){ //Don't output this unless this option is enabled (to prevent empty values from appearing like a lack of activity)
if ( isset($this->super->cookie['attribution']) ){
$debug_info['nebula_attribution'] = sanitize_text_field($this->super->cookie['attribution']);
}
}
//Staff
if ( $this->is_dev() ){
$debug_info['nebula_staff'] = 'Developer';
} elseif ( $this->is_client() ){
$debug_info['nebula_staff'] = 'Client';
} elseif ( $this->is_staff() ){
$debug_info['nebula_staff'] = 'Staff';
}
//Logged-in User Info
if ( is_object($submission) ){
$user_id = (int) $submission->get_meta('current_user_id');
if ( !empty($user_id) ){
$user_info = get_userdata($user_id);
$debug_info['nebula_user_id'] = $user_info->ID;
$debug_info['nebula_username'] = $user_info->user_login;
$debug_info['nebula_display_name'] = $user_info->display_name;
$debug_info['nebula_email'] = $user_info->user_email;
if ( get_the_author_meta('phonenumber', $user_info->ID) ){
$debug_info['nebula_phone'] = get_the_author_meta('phonenumber', $user_info->ID);
}
if ( get_the_author_meta('jobtitle', $user_info->ID) ){
$debug_info['nebula_job_title'] = get_the_author_meta('jobtitle', $user_info->ID);
}
if ( get_the_author_meta('jobcompany', $user_info->ID) ){
$debug_info['nebula_company'] = get_the_author_meta('jobcompany', $user_info->ID);
}
if ( get_the_author_meta('jobcompanywebsite', $user_info->ID) ){
$debug_info['nebula_company_website'] = get_the_author_meta('jobcompanywebsite', $user_info->ID);
}
if ( get_the_author_meta('usercity', $user_info->ID) && get_the_author_meta('userstate', $user_info->ID) ){
$debug_info['nebula_city_state'] = get_the_author_meta('usercity', $user_info->ID) . ', ' . get_the_author_meta('userstate', $user_info->ID);
}
$debug_info['nebula_role'] = $this->user_role();
}
}
//Bot detection
if ( $this->is_bot() ){
$debug_info['nebula_bot'] = 'Bot detected';
}
//Simple spam detection
//Note: this will only block form submissions if the Nebula Spam Agent option is actually enabled. It will always denote when submissions may be potentially be spam.
$normalized_submission = ( is_object($submission) )? (array)$submission : $submission; //Normalize the submission so we can loop through each field
foreach ( $normalized_submission as $key => $value ){
if ( !empty($value) && $this->is_spam_field_data_detected($value) ){
$debug_info['nebula_spam_detection'] = 'Potential spam detected';
break;
}
}
//WPML Language
if ( defined('ICL_LANGUAGE_NAME') ){
$debug_info['nebula_language'] = ICL_LANGUAGE_NAME . ' (' . ICL_LANGUAGE_CODE . ')';
}
//Device information
if ( isset($this->super->server['HTTP_USER_AGENT']) ){
$debug_info['nebula_user_agent'] = sanitize_text_field($this->super->server['HTTP_USER_AGENT']);
}
$debug_info['nebula_device_type'] = ucwords($this->get_device('formfactor'));
$debug_info['nebula_device'] = $this->get_device('full');
$debug_info['nebula_os'] = $this->get_os();
$debug_info['nebula_browser'] = $this->get_browser('full');
//Anonymized IP address
$debug_info['nebula_anonymized_ip'] = sanitize_text_field($this->get_ip_address());
//Geo Data (if available)
if ( !empty($this->get_geo_data('country')) ){
$debug_info['nebula_geo_country'] = $this->get_geo_data('country');
//If additional granular data is available
if ( $this->get_geo_data('city') ){
$debug_info['nebula_geo_region'] = $this->get_geo_data('region');
$debug_info['nebula_geo_city'] = $this->get_geo_data('city');
$debug_info['nebula_geo_metro_code'] = $this->get_geo_data('metro_code');
$debug_info['nebula_geo_postal_code'] = $this->get_geo_data('postal_code');
$debug_info['nebula_geo_coordinates'] = $this->get_geo_data('coordinates');
}
}
$debug_info = map_deep($debug_info, 'sanitize_text_field'); //Deep sanitization of the full data array
return apply_filters('nebula_cf7_debug_info', $debug_info);
}
Override
This function can not be short-circuited with an override filter. Request one?