Title: Before Send action hook
Last modified: August 30, 2016

---

# Before Send action hook

 *  [msummers](https://wordpress.org/support/users/msummers/)
 * (@msummers)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/before-send-action-hook/)
 * I am using WP 4.2.4 and CF7 4.2.2 and I have a form that is loaded from a series
   of links that specify which recipient to use for the form. The links look like–
 * /contact/contact-sales/?t=2
 * Depending on the value of the “t” variable, the form will be directed to the 
   proper recipient.
 * My actionhook looks like this –
 * function wpcf7_do_something (&$WPCF7_ContactForm) {
    if (isset($_GET[‘t’]) &&
   $_GET[‘t’] < 5 && $_GET[‘t’] > 0) { if ($_GET[‘t’] == ‘1’) { $WPCF7_ContactForm-
   >mail[‘recipient’] = “aaaa@example.com”; } else if ($_GET[‘t’]==’2′) { $WPCF7_ContactForm-
   >mail[‘recipient’] = “bbbb@example.com”; } else if ($_GET[‘t’]==’3′) { $WPCF7_ContactForm-
   >mail[‘recipient’] = “ccc@example.com”; } else { $WPCF7_ContactForm->mail[‘recipient’]
   = “dddd@example.com”; } } }
 * add_action(“wpcf7_before_send_mail”, “wpcf7_do_something”);
 * I have saved this in the plugins folder, and activated it via the WP admin, where
   I can visually see that it’s activated.
 * The action is not working.
 * The site was updated very recently from WP3.5.2 to the current version, and I’m
   pretty sure this was working in the previous version. Can anyone see any obvious
   mistakes, or any reason it would stop working in these two current versions of
   WP and CF7?
 * Thanks!
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/before-send-action-hook/#post-6431293)
 * See [Contact Form 7 3.9](http://contactform7.com/2014/07/14/contact-form-7-39/)
 *  Thread Starter [msummers](https://wordpress.org/support/users/msummers/)
 * (@msummers)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/before-send-action-hook/#post-6431316)
 * So, you are saying that instead of this –
 * $WPCF7_ContactForm->mail[‘recipient’] = “ccc@example.com”;
 * I should now use this –
 * $mail=$contact_form->prop(‘mail’);
    $mail[‘recipient’]=”ccc@example.com”; $contact_form-
   >set_properties(array(‘mail’ = $mail));
 * ?
 * Looks reasonable to me…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Before Send action hook’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [msummers](https://wordpress.org/support/users/msummers/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/before-send-action-hook/#post-6431316)
 * Status: not resolved