Skip to content

Instantly share code, notes, and snippets.

@yratof
Created May 15, 2014 12:58
Show Gist options
  • Save yratof/b3a4dda01c0231a4da7f to your computer and use it in GitHub Desktop.
Save yratof/b3a4dda01c0231a4da7f to your computer and use it in GitHub Desktop.
Extra Contact Form Fields
//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-name'] = $cf7->posted_data['your-name'];
$_SESSION['formdata-tele'] = $cf7->posted_data['your-telephone'];
$_SESSION['formdata-age'] = $cf7->posted_data['your-age'];
return false;
}
add_action( 'wpcf7_before_send_mail', 'set_sessions' );
/******
<?php echo $_SESSION['formdata-name']; ?>
<?php echo $_SESSION['formdata-tele']; ?>
<?php echo $_SESSION['formdata-age']; ?>
*******/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment