Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...