Skip to content

Instantly share code, notes, and snippets.

@cfxd
Last active July 6, 2016 15:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfxd/670b81e6265a320d7935 to your computer and use it in GitHub Desktop.
Save cfxd/670b81e6265a320d7935 to your computer and use it in GitHub Desktop.
WordPress Contact Form 7 filter: set your contact form's "To:" field to "%admin%" to automatically use the site admin email dynamically. See http://cfxdesign.com/contact-form-7-dynamic-email-field
<?php
function wpcf7_dynamic_email_field($args) {
if(!empty($args['recipient'])) {
$args['recipient'] = str_replace('%admin%', get_option('admin_email'), $args['recipient']);
return $args;
}
return false;
}
add_filter('wpcf7_mail_components', 'wpcf7_dynamic_email_field');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment