For our WordPress site (which uses Contact Form 7), we wrote some custom php that runs a background process when a specific CF7 is submitted. We did this within our child theme's functions.php, with reference files placed in a sub folder within the child theme.

Code from functions.php:

add_action( 'wpcf7_before_send_mail', 'vul_submit' );
function vul_submit( $contact_form ) {
$title = $contact_form->title;
$submission = WPCF7_Submission::get_instance();

if ( $submission ) {
    $posted_data = $submission->get_posted_data();
if ( 'SVT' == $title ) {
    require dirname(__FILE__) . "/ST/index.php";

The index.php contains or calls on the rest of the code. This currently works great--the intended functions run when a CF7 form with the name "SVT" is submitted.

However, when I try to move this out of the child theme, and instead into a site-specific SVTplugin.php, it no longer works. I followed instructions here http://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/, and moved the above quoted code out of functions.php into its own plugin file (as well as all the supporting files).

I can confirm that the plugin is activated, and that the conflicting function in the original functions.php has been commented out. The form still submits--except nothing happens in the background anymore.

By adding some "debugging" file_put_contents, it appears that SVTplugin.php isn't being called upon form submission. Not sure what the right terminology is, but I suspect the add_action isn't activated here? Do I need a separate do_action or something?

I'm guessing there may be a very simple thing that I'm missing here--any guidance would be appreciated. Thanks!

  • Is there any information in the error log? Is the code removed from the theme's (or child theme) functions.php (in case of function re-declaring)? Aug 15, 2017 at 17:58
  • Hi. Nothing new in the error log. And yeah the code was removed from the child theme's functions.php. Aug 15, 2017 at 18:00
  • what is your plugin directory structure, did you move the ST folder to it?
    – inarilo
    Aug 15, 2017 at 19:50
  • Thanks for reading. The original functions.php has all supporting files in a ST folder; for the plugin I have all the files in a single folder, and so I just require the php files directly without referencing additional pathing. Though I suspect the issue is not with pathing, because I inserted a file_put_contents into the SVTplugin.php function before it goes onto calling the other files, and the text write doesn't actually activate for some reason. Aug 15, 2017 at 20:41
  • Also assuming that the plugin header is proper? Does the plugin appear in the plugin list (it appears so, from your comment that the 'plugin is activate'). When I get funny results during development, or need to check if something is working like I planned (like an 'if' statement), I'll put a 'die("here we are")' statement at the point I need to check, sometimes doing var_dumps of things. Maybe that will help you find the problem. Aug 15, 2017 at 23:10

1 Answer 1


The comments others have left seemed to suggest the process of converting from functions.php to a site specific plugin truly should be straightforward. And so I attempted again, and this time around everything worked. I think I may have had a wrong syntax somewhere that got corrected during the second attempt, when i pasted the code from functions.php fresh.

In short, false alarm. But a big thank you for all the commenters, as without their line of questions I would have given up on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.