Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

How can I get [checkbox] mail tag values into a unordered list inside the email in CF7?

[checkbox services one_label_element "DJ" "Live Dhol" "MC" "Intelligent Dancefloor Lighting" "Uplighting" "Pinspot Lighting"]<


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the Smart Grid extension for CF7, it introduces mail tag filters, so you would do something like,

add_filter( 'cf7sg_mailtag_my-checkbox', 'filter_cf7_mailtag_my_checkbox', 10, 3);
function filter_cf7_mailtag_select_option($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('my-form'==$cf7_key ){
    $tag_replace = '<ul>'.PHP_EOL;
    foreach($submitted['my-checkbox'] as $value){
      $tag_replace .= "<li>{$value}</li>".PHP_EOL;
    }
    $tag_replace .= '</ul>';
  }
  return $tag_replace;
}

The filter is customised for each mail tag, in this example I have a checkbox field called my-checkbox, the plugin create the custom filter and helper code. Please view this video tutorial to understand how to obtain the appropirate filter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.5k users

...