• Resolved terjeset

    (@terjeset)


    Ladies and Gentlemen

    I have spotted a gem amongst all WP plugins, the Contact Form 7. It is a breeze to set up forms and send the input to whatever addresses I migth feel for. And even let me transform the message body into XML or whatever based on the data submitted.

    But I cant find I way to do PHP calculations and feed the result into a tag. I need to add a timestamp (yyyymmddhhmmss) to my message.

    Anyone here who knows how-to?

Viewing 1 replies (of 1 total)
  • Add this code into your theme’s functions.php

    add_filter( 'wpcf7_special_mail_tags', 'wpcf7_special_mail_tag_extension', 10, 2 );
    
    function wpcf7_special_mail_tag_extension( $output, $name ) {
    
    	if ( '_date_YYYYMMDDHHMMSS' == $name )
    		$output = gmdate( 'YmdHis', current_time( 'timestamp' ) );
    
    	return $output;
    }

    Then put [_date_YYYYMMDDHHMMSS] into the Message Body of the Mail section.

Viewing 1 replies (of 1 total)

The topic ‘PHP calculations (code) within a form’ is closed to new replies.