Back to Community

Troubleshooting Common Issues with the Contact Form 7 Database Addon (CFDB7)

16 threads Sep 10, 2025 PluginContact form 7 database addon – cfdb7

Content

The Contact Form 7 Database Addon (CFDB7) is a popular and powerful tool for saving form submissions from the Contact Form 7 plugin. However, like any software, users can occasionally run into issues. Based on community discussions, here are some of the most common problems and their potential solutions.

1. Forms Not Appearing in the List

The Problem: Users report that not all of their Contact Form 7 forms are visible in the CFDB7 form list. This is a frequent issue on multilingual sites using plugins like WPML or Polylang.

Why It Happens: The plugin's query to fetch forms may not be fully compatible with how translation plugins duplicate and manage form posts.

Potential Solutions:

  • Check the pagination at the bottom of the forms list, as forms might be on a different page.
  • This appears to be a known compatibility issue. Users may need to wait for an official update from the 'Contact Form 7 Database Addon – CFDB7' team that addresses multilingual queries.

2. PHP 8.x Compatibility Error on Multisite

The Problem: Upon activating the plugin on a WordPress multisite installation running PHP 8.0 or 8.1, a fatal error occurs: Fatal error: Uncaught Error: Call to a member function add_cap() on null.

Why It Happens: The plugin attempts to add capabilities before all necessary WordPress functions are loaded in the multisite environment under newer PHP versions.

The Solution: A workaround found by the community is to add the following code to your theme's functions.php file. This ensures the required user role functions are loaded.

if ( !function_exists( 'populate_roles' ) ) {
    require_once( ABSPATH . 'wp-admin/includes/schema.php' );
}
populate_roles();

3. Excluding Specific Forms from Being Saved

The Problem: A user may want to prevent CFDB7 from saving submissions for certain forms, for example, to avoid storing spam submissions in the database.

The Solution: This requires a two-part code modification.

  1. Add the following code to your theme's functions.php file to prevent the plugin from saving submissions for forms with IDs 4465 and 5515 (replace these IDs with your own).
    $cfdb_exclude_ids = array( 4465, 5515);
    add_action( 'wpcf7_before_send_mail', 'exclude_wpcf7_before_send_mail', 9);
    
    function exclude_wpcf7_before_send_mail( $form ){
        global $cfdb_exclude_ids;
        $id  = $form->id();
        if( in_array($id , $cfdb_exclude_ids) ){
            remove_action( 'wpcf7_before_send_mail', 'cfdb7_before_send_mail');
        }
    }
    
  2. Modify the plugin file itself to exclude the forms from the admin list. Navigate to plugins > contact-form-cfdb7 > inc > admin-mainpage.php and find the $args array for the form query. Change it to use 'post__not_in' => $cfdb_exclude_ids.
    $cfdb_exclude_ids = array( 4465,5515);
    $args = array(
        'post_type' => 'wpcf7_contact_form',
        'order' => 'ASC',
        'post__not_in' => $cfdb_exclude_ids
    );
    
    Important Note: Any changes made to the plugin's core files will be overwritten when the plugin is updated. This solution is a temporary workaround.

4. Displaying Submission Counts on the Front End

The Problem: Users wish to display the number of submissions for a specific form somewhere on their website's front end.

The Solution: You can retrieve the count by running a custom database query. The following code snippet can be placed in a template file or within a custom function.

global $wpdb;
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
$table_name = $cfdb->prefix.'db7_forms';
$form_post_id = 123; // Change 123 to your actual Form ID
$submission_count = $cfdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE form_post_id = $form_post_id" );

echo $submission_count; // This displays the count

General Advice

  • Always create a full backup of your site before adding custom code or modifying plugin files.
  • When adding code to your theme's functions.php file, consider using a child theme to prevent your changes from being lost during a theme update.
  • Many of these solutions are community-provided workarounds. For permanent fixes, keep an eye on the official plugin changelog for updates that address these common issues.