Contact Form 7 Change Action URL

To send form output to a different file put this in themes functions.php.

This code also limits this change to page 434 and adds the $wpcf7->skip_mail function to stop the form sending an email.

//change action url of contact form
add_filter(‘wpcf7_form_action_url’, ‘wpcf7_custom_form_action_url’);
function wpcf7_custom_form_action_url($url)
global $post, $wpcf7;
if ($post->ID === 434) {
//its the payments page
// stop email being sent
$wpcf7->skip_mail = 1;
return ‘/wp-content/themes/mytheme/refresh.php’;

} else {
return $url;

Form data is POSTed to refresh.php but the form ajax will keep the initial page loaded.

To redirect to the second file you can disable the Contact Form 7 scripts as described here

This removes validation but this can be added using a custom script