Title: before send mail function not getting called
Last modified: August 21, 2016

---

# before send mail function not getting called

 *  [Danielle](https://wordpress.org/support/users/secretfamiliesmc/)
 * (@secretfamiliesmc)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/)
 * In the process of updating my functions.php to work with v3.9, my function is
   not getting called and causing the following debug error:
    [03-Aug-2014 21:25:
   33 UTC] PHP Warning: Parameter 1 to wpcf7_attach_instructions() expected to be
   a reference, value given in /home/danbro89/staging.secretfamiliesmc.org/wp-includes/
   plugin.php on line 470
 * This is the function:
    /* function wpcf7_attach_instructions(&$WPCF7_Form) { //
   check if it is the Team Sign Up form if ($WPCF7_Form->id()==405) { // get the
   dropdown menu value and the corresponding instruction file $submission = $WPCF7_Submission::
   get_instance(); if ($submission) { $myDocName = $submission->get_posted_data(‘
   TeamType’).”.pdf”; } $mail_2 = $WPCF7_Form->prop(‘mail_2’); $mail_2[‘attachments’]
   = “uploads/Instructions/”.$myDocName ; $mail_2[‘attachments’] = “\nuploads/Instructions/
   TeamSignUp.pdf”; // attach team sign up sheet $WPCF7_Form->set_properties(array(‘
   mail_2’ => $mail_2)); error_log(“***********WRITTING TO LOG *******************”);
   error_log($mail_2); } } add_action(“wpcf7_before_send_mail”,”wpcf7_attach_instructions”);
 * */
 * my site is [http://www.staging.secretfamiliesmc.org](http://www.staging.secretfamiliesmc.org)
 * Thanks for your assistance.
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

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

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156680)
 * Remove “`&`” from `&$WPCF7_Form`.
 *     ```
       function wpcf7_attach_instructions(&$WPCF7_Form) {
       ```
   
 *  Thread Starter [Danielle](https://wordpress.org/support/users/secretfamiliesmc/)
 * (@secretfamiliesmc)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156713)
 * Thanks so much for the quick reply. I am pretty rusty at coding (been out of 
   the loop for 8 years), so do I need to alter the lines that use $WPCF7_Form then?(
   to get the form id, mail_2 access for the attachment field)
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156724)
 * Just replace `&$WPCF7_Form` to `$WPCF7_Form`.
 *  [fyaconiello](https://wordpress.org/support/users/fyaconiello/)
 * (@fyaconiello)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156776)
 * before the plugin updated (I’m not sure what version I was running previous, 
   but it couldn’t have been more than 2 months old) This hook was calling correctly:
 * add_action( ‘wpcf7_before_send_mail’, array(&$this, “contact_forms_post_submit”),
   10, 2 );
 * class Candidate
    { function contact_forms_post_submit( &$contactform ) { …. }}
 * and then inside that function I could use things like: $contactform->posted_data[“
   text-79”];
 * now if I pass by reference I get the above php warning, and if I don’t, my $contact_form
   doesn’t have a posted_data member and I cannot add dynamic recipients to the 
   form
 *  [fyaconiello](https://wordpress.org/support/users/fyaconiello/)
 * (@fyaconiello)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156777)
 * I’m running
    - Contact Form 7: Version 3.9
    - Contact Form 7 – Dynamic Text Extension: Version 1.1.0.2
    - Contact Form 7 widget: Version 1.0
    - Contact Form DB: Version 2.8.5
    - WordPress: 3.9.1
 *  [iuttu](https://wordpress.org/support/users/iuttu/)
 * (@iuttu)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156868)
 * Same problem here. Any way to fix it? I cannot modify WPCF7_Form inside the hook
   =(

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

The topic ‘before send mail function not getting called’ 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/)

 * 6 replies
 * 4 participants
 * Last reply from: [iuttu](https://wordpress.org/support/users/iuttu/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/before-send-mail-function-not-getting-called/#post-5156868)
 * Status: not resolved