• johnnykoo

    (@johnnykoo)


    Hello, I’m using contact form 7 with cf7-zendesk to create a ticket from the contact form.

    It seems like description field from zendesk must be required not empty. However, I want my user (customer) can omit the description becuase I’m passing other fields (question type dropdown and etc)

    I know I can do that by forcing the user to put some text values in the description but I don’t want to because it will make my user experience bad

    Is there a way I can do that by configuring in cf7-zendesk plugin? (I’m using pro version)

    I even tried to hijack by installing my custom plugin with below code but i got fatal error when i tried to activate it

    <?php
    
    /*
    
    Plugin Name: MWS form default description
    
    Description: never leave empty description field in contact form 7
    
    Version: 1.0
    
    Author: Johnny Ilmo Koo at Kooslab
    
    */
    
    function set_default_description($contact_form) {
    
    $submission = WPCF7_Submission::get_instance();
    
    if ($submission) {
    
    $data = $submission->get_posted_data();
    
    if (empty($data['your-message'])) {
    
    $data['your-message'] = 'no detailed description';
    
    // Update the posted data with the default description
    
    $submission->set_posted_data($data);
    
    }
    
    }
    
    }
    
    /* Before sending contact form using contact form 7 plugin,
    
    * if description field is empty, set default value because zendesk requires it*/
    
    add_action('wpcf7_before_send_mail', 'set_default_description');
  • The topic ‘check empty field and if so, set default value for textarea field’ is closed to new replies.