Contact Form 7 Dynamic Email Field


Contact Form 7,Snippets,WordPress Filters

When I develop a site, my final pre-deploy checklist includes a reminder to change any email addresses used during development to the new admin’s email because during development I like to make sure all site notices go to my test inbox instead of nuking my client’s inbox.

Contact Form 7 lets you send contact form emails to any address. By default, it will use the site admin address which it pulls in from WordPress’s admin email setting once, which means if you change the WordPress admin email after deployment then you still need to remember to change the CF7 mail to field.

I did not want this extra step so I setup a little filter which allows me to change the CF7 mail to field once when I setup the form and leave it alone.

Let’s Do It

First I change the CF7 mail to field to %admin%, then I add this filter to my theme’s functions file (usually functions.php):

Now you can remove an item from your delivery or pre-launch checklist because when you change the admin email the CF7 mail will change simultaneously.


  1. Changing the To field to %admin% gives me this ‘This field has syntax errors.’ and then won’t run — How can I bypass that?

    Thanks this is really helpful.

  2. Hello,
    thanks for this very helpful code. I changed the following:

    $user_email = get_the_author_meta(‘user_email’);
    $args[‘recipient’] = str_replace(‘%admin%’, $user_email, $args[‘recipient’]);

    can u help me because this code doesnt work…
    thx manfred

Leave a Comment