⌘K
  1. Home
  2. Docs
  3. CF7 GSheetConnector
  4. Action and Filter Hooks – PRO Version
Developer Guide

Action & Filter Hooks – Repeatable Fields Compatibility (PRO Version)

CF7 Google Sheet Connector is built to work smoothly with most Contact Form 7 addons out of the box. But repeatable fields work a little differently – a single field can hold multiple sets of values, and Google Sheets needs each of those sets sent over as a separate row.

To handle this, we’ve extended CF7 Google Sheet Connector with dedicated Action and Filter Hooks. If you’re using the CF7 – Repeatable Fields addon and want to send each repeated entry to Google Sheets, you can do this by adding a small snippet of code to your site.

Before you start: Add this code to your active child theme’s functions.php file, not your main theme. If you’re currently using a parent theme without a child theme, create one first – editing your main theme’s files directly means your changes will be lost on the next theme update.

How This Hook Works

The gsc_filter_form_data filter lets you intercept your form’s submitted data before it’s sent to Google Sheets, and reshape it into an array – with one array item per repeated entry. CF7 Google Sheet Connector then loops through that array and adds each item as its own row in your connected sheet.

The Code

Add the following snippet to your child theme’s functions.php file:

/**
* Hook - apply_filters( 'gsc_filter_form_data', $data, $form );
* As Repeatable Fields have multiple data we need to pass values to Google Sheet in Array Format
*/
add_filter('gsc_filter_form_data', function ($data, $form) {
    $output = [];
    // If your form id (Post ID in the URL while editing the form ) is in the given array then proceed
    if (in_array($form->id(), [147, 170])) {
        // Get the Posted data provided by CF7 on form submission.
        $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
        $row = $data;
        // Get count for any one field to loop and get the count of repeatable fields
        $counter = 0;
        foreach ($posted_data as $key => $values) {
            if (is_numeric(strpos($key, "your-email"))) {
                $counter = $counter + 1;
            }
        }
        
        // Loop and create array values
        for ($i = 1; $i>= $counter; $i++) {
            $row['your-email'] = $posted_data['your-email__' . $i];
            
            // for radio, dropdown and checkbox
            $row['your-radio'] = $posted_data['your-radio__' . $i][0];
            $row['your-menu'] = $posted_data['your-menu__' . $i][0];
            $row['your-checkbox'] = $posted_data['your-checkbox__' . $i][0];
            $output[] = $row;
        }
    }
    return $output;
}, 10, 2);

Customizing the Code for Your Form

This snippet needs two things updated before it will work on your site: your Form ID and your field names.

1. Update the Form ID

In the line below, 147 and 170 are example Form IDs. Replace them with the ID(s) of the form(s) you want this behavior applied to:

if (in_array($form->id(), [147, 170])) {...}

You can find your Form ID in the URL when editing your Contact Form – it’s the number shown as the Post ID.

Finding the Contact Form 7 Form ID and repeatable field names
Locate your Form ID from the Contact Form edit link, and match your repeatable field names in the code.

2. Update the Field Names

The example code references fields named your-email, your-radio, your-menu, and your-checkbox. Replace these with the actual field names used in your repeatable field group, exactly as they appear in your Contact Form 7 form.

Note: Repeatable Fields stores each repeated value with a numbered suffix (like your-email__1, your-email__2). The loop in this snippet uses that pattern to pull each repeated set of values into its own row.

What’s Next?

Once your repeatable fields are syncing correctly, you can further customize what gets sent to Google Sheets using the Hooks to Use Custom Mail Tags guide, or fine-tune column headers and styling in the Plugin Settings – PRO Version guide.

Frequently Asked Questions

Do I need the CF7 Repeatable Fields plugin for this to work?

Yes. This hook is specifically designed to work alongside the CF7 – Repeatable Fields addon. Without it, your form won’t generate the numbered field names this code expects.

Where do I find my Contact Form 7 Form ID?

Open your Contact Form for editing in the WordPress dashboard and check the Post ID shown in the browser’s address bar – that number is your Form ID.

Can I apply this hook to multiple forms at once?

Yes. Add each Form ID you want covered inside the array, for example in_array($form->id(), [147, 170, 205]).

Why should I use a child theme instead of editing my main theme directly?

If you edit your main (parent) theme’s files directly, all your changes will be lost the next time that theme is updated. A child theme keeps your customizations safe and separate from the original theme files.

Is this feature available in the Free version?

No. Action and Filter Hooks for advanced use cases like repeatable fields are a PRO feature of CF7 Google Sheet Connector.

My repeatable field data isn't showing up correctly in Google Sheets. What should I check?

Verify that your Form ID is correctly added to the array, your field names in the code exactly match your form’s actual field names, and that the CF7 – Repeatable Fields plugin is active and properly configured on your form.

Can I customize this code for field types other than email, radio, menu, and checkbox?

Yes. The example code covers common field types, but you can add or modify the field mappings inside the loop to match whatever repeatable fields your form actually uses.

What happens if I don't add my Form ID to the array?

The custom logic in this snippet will simply be skipped for that form, and CF7 Google Sheet Connector will fall back to its default behavior for syncing form data.

Still not using GSheetConnector?
Quick and easy setup ⚙️ seamlessly import your settings from any other Google Sheets plugin!
👉 Learn more about the Pro Version | Download the Free Version