Modify Contact Form 7 Submission Data

后端 未结 1 484
夕颜
夕颜 2020-12-10 21:54

I\'m using Contact Form 7 on a site and need to alter the checkbox submitted data. The checkbox has a label called \'Tick here if you dont want to receive further marketing\

相关标签:
1条回答
  • 2020-12-10 22:36

    I believe you can just use:

    // define the wpcf7_posted_data callback 
    function action_wpcf7_posted_data( $array ) { 
        //'checkbox-name' is the name that you gave the field in the CF7 admin.
        $value = $array['checkbox-name'];
        if( !empty( $value ) ){
            $array['checkbox-name'] = "New Value";
        }
    
        return $array;
    }; 
    add_filter( 'wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1 );
    
    0 讨论(0)
提交回复
热议问题