Forum Replies Created

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

    (@tierramitica1)

    I did it!!! I spent a few hours delving into PHP and got my code to work! The email looks perfect now with a nice organized table. I committed to a five day PHP crash course thanks to you and looking forward to learn more. Thanks again.

    Sharing it here in case other people are interested:

    add_filter( 'cf7sg_mailtag_cf7sg-form-registration-form-2', 'filter_cf7_mailtag_cf7sg_form_registration_form_2', 10, 3);
    function filter_cf7_mailtag_cf7sg_form_registration_form_2($tag_replace, $submitted, $cf7_key){
      /*the $tag_replace string to change*/
      /*the $submitted an array containing all submitted fields*/
      /*the $cf7_key is a unique string key to identify your form, which you can find in your form table in the dashboard.*/
      if('registration-form-2'==$cf7_key ){
        $style = 'style="padding:0 3px;border-collapse:collapse;border-bottom:1px solid black[qtm]';
        $tag_replace ='
        <table>
          <thead><tr><th>Guest Name</th><th>Passport number</th><th>Age</th><th>Sex</th></tr></thead>
          <tbody>';
        if(!empty($submitted['full-guest-name'])){
          $style = 'style=[qtm]background-color:#e3e3e3[qtm]';
          $row=1;
          foreach($submitted['full-guest-name'] as $idx=>$guest){
            $tag_replace .='  <tr><td '.($row%2==0?$style:'').'>'.$guest.'</td><td '.($row%2==0?$style:'').'>'.$submitted['passport-number'][$idx]. '</td><td '.($row%2==0?$style:'').'>'.$submitted['age'][$idx]. '</td><td '.($row%2==0?$style:'').'>'.$submitted['sex'][$idx]. '</td></tr>'.PHP_EOL;
            $row++;
          }
        }
        $tag_replace .='
          </tbody>
        </table>
        ';
      }
      return $tag_replace;
    }
    Thread Starter tierramitica1

    (@tierramitica1)

    I understand, thanks though!

Viewing 2 replies - 1 through 2 (of 2 total)