首页 > 解决方案 > 如何将 [checkbox] 邮件标签值放入 CF7 中电子邮件内的无序列表中?

问题描述

[复选框服务 one_label_element “DJ” “Live Dhol” “MC” “智能舞池照明” “Uplighting” “Pinspot Lighting”]<

标签: emailcheckboxtagscontact-form-7

解决方案


使用CF7 的 Smart Grid 扩展,它引入了邮件标签过滤器,所以你会做类似的事情,

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;
}

过滤器是为每个邮件标签定制的,在这个例子中,我有一个名为的复选框字段my-checkbox,插件创建自定义过滤器和帮助代码。请观看此视频教程以了解如何获取合适的过滤器。


推荐阅读