Contact Form 7 code :
[hidden url_redirect "https://wp-experts.gr/"]
Check hidden field documentation here
functions.php code :
//Get hidden redirect cf7 field from each form and redirect there
function wpe_cf7form_redirect(){
?>
<script>
document.addEventListener( 'wpcf7mailsent', function( e ) {
var url_redirect = '';
var dtas = e.detail.dtas;
for ( var i = 0; i < dtas.length; i++ ) {
if( 'url_redirect' == dtas[i].name ) {//used for misc forms
url_redirect = dtas[i].value;//set the redirect value from current submitted form
}
}
//Check for redirect
if( url_redirect ){
location = url_redirect;
}
}, false );
</script>
<?php
}
add_action( 'wp_footer', 'wpe_cf7form_redirect' );