• I am developing a plugin that uses contact forms 7. I am having a challenge in getting the wpcf7_before_send_mail action to fire. I have disabled all the plugins except contact forms 7 and my own plugin and it still won’t fire. All I am doing right now is trying to write to log (see code below), but I will be using the action to save form data to database.

    We are also using:
    – Virtue Theme version 2.5.8
    – Multisite WordPress

    	add_action('wpcf7_before_send_mail','cf7_save_to_the_database');
    
    	function cf7_save_to_the_database($cf7) {
    
    		write_log("-----------SAVING RESULTS TO DATABASE----------");
    	}
    

    Thanx

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter raz0r7

    (@raz0r7)

    Just and update. I got the action/webhook to fire by

    I want to use the wpcf7_before_send_mail action in a custom page template. Just wondering why it wouldn’t fire even though it does fire if I place the function and action in the theme “functions.php” file.

    I am going to use this “cf7_save_to_the_database” function to store my data.

    See the code below to see how I am trying to implementing this:

    	//WP hooks start
    	add_filter('the_content', 'post_page');
    	//WP hooks end
    
    	function post_page($content){
    		global $post; //wordpress post global object
    
    		write_log("-----------QUIZ TEMPLATE TEST----------");
    
    		add_action('wpcf7_before_send_mail','cf7_save_to_the_database', 0);
    
    		return $content;
    	}
    
    	function cf7_save_to_the_database($cf7) {
    
    		write_log("-----------SAVE RESULTS TO DATABASE HERE----------");
    
    		$submission = WPCF7_Submission::get_instance();
    		if ( $submission ) {
    		    $formdata = $submission->get_posted_data();
    		}
    		write_log($formdata);
    
    	}

    Everything works fine when I put the action and cf7_save_to_the_database function in the theme “functions.php” file.

    – Also, we aren’t using multisite in this wordpress.

    Thanx

    Thread Starter raz0r7

    (@raz0r7)

    BTW, “Just and update. I got the action/webhook to fire by” should read “Just an update. I got the action/webhook to fire by placing the action and function in “functions.php”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wpcf7_before_send_mail action not firing’ is closed to new replies.