WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Add solution for 3rd party integration and managing errors (4 posts)

  1. klode
    Member
    Posted 1 year ago #

    I have reverse engineered a piece of your plugin.

    In the file includes/classes.php, in the row 480, where there's a control in skip_mail parameter, I have added this code:

    global $wpcf7;
    if ( $this->skip_mail )
    {
    	if(isset($wpcf7->result["valid"]))
    		if($wpcf7->result["valid"] == 1) return true;
    		else return false;
    	else
    		return true;
    }

    In this mode, when there is a control with 3rd party integration, it's possible to set:

    global $wpcf7;
    $wpcf7->result["valid"] = 0; //in case of error
    $cf7->skip_mail = true;

    in order to declare the variable "mail_sent" on ajax response to false. Again, with this code:

    $cf7->messages["mail_sent_ng"] = "Some error occured!";

    it's possible to customize the message on return from Server.

    That's it!

    I hope this my little editing can help someone!!!

    http://wordpress.org/extend/plugins/contact-form-7/

  2. biswajeet
    Member
    Posted 1 year ago #

    Thanks. btw, messages are already customizable...

  3. rospo85
    Member
    Posted 1 year ago #

    biswajeet, what can I do to customize my message?
    I need to do it programmatically, not by the CF7 setting panel!
    Do you have an option different by the one of klode?
    klode, your solution work well for me, but i don't like to hack the plugin code if i can...

  4. zaus
    Member
    Posted 12 months ago #

    I'd suggest looking at how my plugin http://wordpress.org/extend/plugins/forms-3rdparty-integration/ hooks to the wpcf7_before_send_mail action to alter the $form->messages['mail_sent_ok'] (screen message) or $form->mail['body'] (email). Main point is never alter plugin code if they provide hooks, and CF7 is good about providing a lot of hooks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic