skip to Main Content

WordPress Code Snippets


Redirect After Submission in Contact Form 7

You can easily redirect users to a thank you page after they submit the form. This enhances user experience and confirms successful submissions.

add_action('wpcf7_mail_sent', 'codebykp_redirect_after_submission');

function codebykp_redirect_after_submission($contact_form) {
    $redirect_url = home_url('/thank-you');
    echo '<script type="text/javascript">window.location.href = "' . $redirect_url . '";</script>';
}


I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search