Skip to content

Instantly share code, notes, and snippets.

@yratof
Created May 15, 2014 08:43
Show Gist options
  • Save yratof/afb46c218d1c42fb0877 to your computer and use it in GitHub Desktop.
Save yratof/afb46c218d1c42fb0877 to your computer and use it in GitHub Desktop.
Contact Form 7 - Custom Thanks Page
on_sent_ok: "location = 'http://www.formless.me/thank-you';"
//This will start a session, then save the posted_data[something] to the session
add_action('init', 'myStartSession', 1);
add_action('wp_logout', 'myEndSession');
add_action('wp_login', 'myEndSession');
function myStartSession() {
if(!session_id()) {
session_start();
}
}
function myEndSession() {
session_destroy ();
}
function set_sessions($cf7){
$_SESSION['formdata'] = $cf7->posted_data['your-name'];
return false;
}
add_action( 'wpcf7_before_send_mail', 'set_sessions' );
<h1 class="thankyou">Thank You <?php echo $_SESSION['formdata']; ?></h1>
<h2 class="thankyou-when">Your form has been successfully submitted! You can expect to hear back from us within 1-2 business days</h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment