Add custom code

Some guides in this documentation use PHP snippets that hook into the plugin with filters and actions. Do not add them to the plugin files: every update replaces those files and your code is lost.

There are two places for this code: a small plugin of your own, which is what WordPress recommends, or a snippets plugin, if you prefer not to edit files.

A plugin of your own

Create the folder wp-content/plugins/cf7-to-webhook-custom/ and, inside it, the file cf7-to-webhook-custom.php:

<?php
/**
 * Plugin Name: CF7 to Webhook customizations
 * Description: Custom code for CF7 to Webhook.
 * Version:     1.0.0
 */

defined( 'ABSPATH' ) || exit;

// Add your snippets below this line.

Then activate "CF7 to Webhook customizations" in Plugins. The comment block at the top is what makes WordPress recognize the file as a plugin, as explained in Plugin Basics.

To keep the code from being deactivated by mistake, put the same file in wp-content/mu-plugins/ instead. WordPress loads must-use plugins on its own, and they cannot be deactivated in the admin.

The theme's functions.php also runs PHP, but the code goes away when you switch themes or a theme update replaces the file.

A snippets plugin

A plugin like Code Snippets lets you add PHP from the admin, without editing files. Create a snippet, paste the code without the opening <?php and set it to run everywhere: forms are sent outside the admin, so a snippet limited to the admin area does not run for them.

Before you save

An error in PHP code can take the site down. Test the snippet on a staging copy first. If the site breaks, rename the plugin folder over FTP to deactivate it, or use the safe mode of your snippets plugin.