Quantcast
Channel: Topic Tag: action | WordPress.org
Viewing all articles
Browse latest Browse all 889

FeralReason on "Add a Custom Mail Tag to Contact Form 7"

$
0
0

Takayuki, modeled this off of your 'wpcf7_special_mail_tag' function in mail.php, and added it to my site-specific plugin. Seems to work like a charm -- and provides me with a way to continue adding special mail tags :)

add_filter( 'wpcf7_special_mail_tags', 'custom_mail_tag', 10, 3 );

function custom_mail_tag( $output, $name, $html ) {
	$name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat

	$submission = WPCF7_Submission::get_instance();

	if ( ! $submission ) {
		return $output;
	}

  if ('_landingpage' == $name) {
      $cookie_name = "landingPage";
      if(!isset($_COOKIE[$cookie_name])) {
          return 'Original page not retrievable.';
      } else {
          return  $_COOKIE[$cookie_name];
      }
  }

  return $output;
}

Let me know if anything looks like it could use improvement.

Thanks again !!


Viewing all articles
Browse latest Browse all 889

Trending Articles