• Hi

    I am relatively new to wordpress and needed some help with the contact form 7 plugin.
    I tried to create a hook for wpcf7_before_send_mail by adding the following piece of code in the functins.php file of my active theme:

    function update_message_body($cf7){
    	if($cf7->id == 7){
    		$name = $cf7->posted_data["your-name"];
    		$cf7->mail['body'] = "Hello ".$name;
    	}
    }
    add_action("wpcf7_before_send_mail", "update_message_body");

    The purpose is to generate the message body dynamically based on user inputs and this code is just an initial test.
    After clicking the send button, however, the spin arrows keep rotating without giving the success message. Even though, the mail is delivered, the message body is not generated as required. Moreover, when this piece of code is removed the issue with the send arrows disappear indicating that there is some issue with my code.

    Could you tell me what I am doing wrong and how to troubleshoot this.

    I am using wordpress v3.9.2, contact form 7 v3.9.1.

    Thanks
    Varun

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 3 replies - 16 through 18 (of 18 total)
  • Many thanks tristanslater !
    It works perfectly.

    tristanslater,

    This was super helpful – really, thanks! Found lots of pieces of this, but none that quite put it together since the recent update. This makes perfect sense now, thank you for sharing!!

    -D

    hi i have next function in signle php /////////////////////////
    $total = ( $a * $b ) + ( $c * $d ) + ( $e * $b ) + ( $f * $d );
    echo “<tr><td>Ukupno</td><td width=’200′><input type=’text’ name=’amount’ value=’$total’></td></tr>
    “;//////////////////////////////////
    how to insert this code in $mail[‘body’] .=

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Issue with wpcf7_before_send_mail’ is closed to new replies.