• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WBXPress.NET

Website Developement Guide

  • apache2
  • nginx
  • mysql
  • php7
  • SSL
  • wordpress
  • genesis
  • caching
  • seo

Contact Form 7 – Change Email Recipient

Updated on 9th September 2017 8 Comments

There is a shortcut method to change email recipient when contact form is submitted.

Add below code in functions.php. It will change email recipient for contact form 7.

// hook into wpcf7_before_send_mail
add_action( 'wpcf7_before_send_mail', function($contact_form){
 
// create new instance of WPCF7_Submission class
$submission = WPCF7_Submission::get_instance();
 
// email address you want to change
$toEmail = 'abc@xyz.com';
 
// set the email address to recipient
$mailProp = $contact_form->get_properties('mail');
$mailProp['mail']['recipient'] = $toEmail;
 
// update the form properties
$contact_form->set_properties(array('mail' => $mailProp['mail']));
 
});

Filed Under: wordpress

Reader Interactions

Comments

  1. Sahil says

    24th September 2017 at 10:59 pm

    Thanks for sharing ! but i dont know y contact form 7 plugin dont works for me !

    Reply
    • wbxpress says

      27th September 2017 at 8:16 pm

      After activation of contact form 7 plugin what problems you are facing?

      Reply
  2. Robert Mercury says

    17th November 2017 at 2:06 pm

    Which one is better: or Freedom Contact Form 7 or WPForms ?

    Reply
  3. avi says

    14th December 2017 at 10:50 pm

    how to add a contact form on blogger

    Reply
  4. Dev says

    26th February 2018 at 9:39 pm

    Thanks for sharing ! facing problem with this please help..
    cotnact 7 form pluging not working..

    Reply
  5. Hovo says

    18th September 2018 at 8:36 pm

    Hi, thanks for sharing.
    How can I send same mail to multiple recipients ?
    Thank you

    Reply
    • tiz says

      11th October 2018 at 2:27 pm

      did you get an answer? i need it also

      Reply
  6. tiz says

    11th October 2018 at 2:28 pm

    multiple recipients ? some one??

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Most Popular Posts

  • Remove/ Defer Render-blocking JavaScripts
  • Customizing Genesis eleven40-pro Theme
  • Free Genesis Child Theme by WBXPress
  • Host Multiple Sites with SSL in Ubuntu 18.04
  • 25 Ways to Boost Website Traffic that Really Work

Recent Comments

  • Ruhul on Customizing Genesis eleven40-pro Theme
  • Priya Agarwal on Customizing Genesis eleven40-pro Theme
  • mimi roy on Remove/ Defer Render-blocking JavaScripts
  • danish choudhary on Customizing Genesis eleven40-pro Theme
  • Radhe on Customizing Genesis eleven40-pro Theme

Copyright © 2021 · Powered by WordPress · Log in