I have multiple Contact form 7 on wordpress and I want one form to redirect with send post data to other domain page. I have added below code in functions.php for redirect my specific contact form,data was send successfully but page was not redirecting.
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url($url)
{
global $post;
$id_to_change = 5240;
if($wpcf7_contact_form->ID === $id_to_change)
return 'http://34.209.247.91:8069/page/register';
else
return $url;
}
The following is an example of script that redirects you to another URL when the wpcf7mailsent event occurs.
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'http://example.com/';
}, false );
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.