I have been looking for a solution to this, have seen some sort of add on called dynamic text but I don't think that suits my needs.

Basically, I have a multi dimensional array. Basically what I want to do is pass a value from the array into the 'to' field in Contact Form 7. I know I could just write my own contact form but I'm using the plugin quite extensively on the site so for integration it would be nice to use it for this new thing I'm building too. Any clues, doesn't seem you can put php straight in to the to field, as this didn't work to well!:

<?php echo $passmein;?>

1 Answer 1


Contact Form 7 has a lot of useful hooks you can use to tie custom code into it at various points of the form submission process. They are tragically not well documented at all but you can find them by googling around. You probably want wpcf7_before_send_mail. Something like this in functions.php:

function do_stuff($wpcf7) {
    // do whatever you need to the $wpcf7 data object
    return $wpcf7;
add_action('wpcf7_before_send_mail', 'do_stuff');
  • Hi, thanks, looks promising. Guessed it would be something like: $_POST['wpcf7-mail-recipient'] = '[email protected]'; but no joy
    – David
    Jul 10, 2013 at 15:04
  • 2
    As said in the php-comment you got to apply your changes to the $wpcf7 variable. Do something like var_dump($wpcf7); exit(); then you'll see what's the name of the variable. You then need to apply your changes like $wpcf7->your_var_name = '[email protected]';
    – s1lv3r
    Jul 10, 2013 at 18:51

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