Skip to content

Instantly share code, notes, and snippets.

@mishterk
Created October 4, 2019 23:48
Show Gist options
  • Save mishterk/70bb486baac349c29b684346b77826ce to your computer and use it in GitHub Desktop.
Save mishterk/70bb486baac349c29b684346b77826ce to your computer and use it in GitHub Desktop.
Intercept and modify the payload sent by Advanced Forms
<?php
// Set the form key you wish to target
$form_key = 'form_5d97cf9edc0a8';
add_action( "af/email/before_send/key=$form_key", function ( $email, $form ) {
add_filter( 'wp_mail', function ( $data ) use ( $email ) {
// you can override any items in this array to customise the email that is sent...
// $data['to'];
// $data['subject'];
// $data['message'];
// $data['headers'];
// $data['attachments'];
// e.g;
$data['subject'] = 'This is a custom subject';
return $data;
} );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment