I finally have a solution that works. The basics of the code is as follows. In my custom functions.php file:
// ensure a session is started even if running via an AJAX call.
if (!session_id()) {
session_start();
}
function interceptCf7 ($cf7Form) {
$cf7 = WPCF7_ContactForm::get_current();
$submission = WPCF7_Submission::get_instance();
// if a form was submitted
if ( $submission ) {
$_SESSION[cf7Data] = $submission->get_posted_data();
}
// don't send the email
$cf7->skip_mail = true;
}
add_action("wpcf7_before_send_mail", "interceptCf7");
I also configure the extra settings in my form admin with this:
on_sent_ok: "location = 'http://myWebSite/myPage';"
With that, I have access to he form data so I can do whatever I want with it. Submit it to a database, display in on the web page, pre-fill a PayPal form, whatever.
I had tried using $_SESSION earlier, but it failed because I called session_start() in header.php, but header.php is not going to be included during an AJAX call. Realizing that, and adding another session_start() call where my custom functions exists so that during AJAX call, a session will be started, gave me access to the data that I wanted in the way that I wanted it.
NOTE that the above code would be applied to ALL contactForm7 forms. I haven’t tested it yet but I believe it may be possible to check one of the following variables to test if the desired form is the one being processed (placed inside my “interceptCf7 function above”)
$cf7 = WPCF7_ContactForm::get_current();
// check one of these to see if it matches the desired form
$cf7->id // ex: 867
$cf7->name // ex contact-form-1
$cfg7->title // ex Contact form 1
Hopefully this helps someone else.