WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
modify submit.result['message'] in hook (2 posts)

  1. lilike
    Member
    Posted 1 year ago #

    Hello All,

    is there a way to modify the $result object in the hooked function on wpcf7_mail_sent action hook? ('my_message_1' and 'my_message_2' are newly/hacky added to wpcf7_messages in /cf7/includes/functions.php)

    function my_wpcf7_mail_sent_hook( $form ) {
        $title = $form->title;
    
        if ( 'First Form' == $title ) {
            require_once('FIRST.class.php');
            $first = new FIRST();
    
            if ( $first->function() ) {
                $form->result['message'] = $form->message('my_message_1');
    
            } else {
                $form->result['message'] = $form->message('my_message_2');
            }
    
        } elseif ( 'Second Form' == $title ) {
            ...
        }
    }
    add_action( 'wpcf7_mail_sent', 'my_wpcf7_mail_sent_hook');

    Thank you in advance,
    Lili

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

  2. lilike
    Member
    Posted 1 year ago #

    Found a solution: defining $result as a proprety of WPCF7_ContactForm class and use that in the submit(ajax) method.

    Can you help me to replace that with a hack-free resolution?

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic