You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在现有do_shortcode函数中添加第二个frm-condition条件短代码

功能实现代码修改方案

你只需要修改mepr_add_tabs_content函数内的代码即可,根据你的使用场景分为两种实现方式:


场景1:两个验证规则独立,满足对应条件就展示对应内容

比如字段ID80有内容则展示ID5728的内容,新增字段ID90有内容则展示ID5729的内容,两个规则互不干扰,都满足就都展示。
修改后的代码如下:

function mepr_add_tabs_content($action) {
  //Listens for the "member-profile" action on the account page, before rendering the FF view shortcode.
  if($action == 'member-profile') {
    // 原有第一段短代码
    echo do_shortcode('[frm-condition source=frm-stats id=80 type=count user_id=current greater_than=0] [display-frm-data id=5728] [/frm-condition]');
    // 新增第二段短代码,把id=90、id=5729替换成你实际要用的ID即可
    echo do_shortcode('[frm-condition source=frm-stats id=90 type=count user_id=current greater_than=0] [display-frm-data id=5729] [/frm-condition]');
  }
}

场景2:需要同时满足两个验证规则才展示内容

必须字段ID80和新增的字段ID90都有内容,才展示对应内容,修改后的代码如下:

function mepr_add_tabs_content($action) {
  //Listens for the "member-profile" action on the account page, before rendering the FF view shortcode.
  if($action == 'member-profile') {
    // 嵌套两个frm-condition规则,两个条件都满足才会展示中间的内容
    echo do_shortcode('[frm-condition source=frm-stats id=80 type=count user_id=current greater_than=0][frm-condition source=frm-stats id=90 type=count user_id=current greater_than=0] [display-frm-data id=5728] [/frm-condition][/frm-condition]');
  }
}

注意事项

你只需要把代码里的示例ID(字段ID、展示短代码ID)替换成你实际业务使用的ID即可,其余原有代码不需要做任何调整。

内容的提问来源于stack exchange,提问作者camfil26

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 13:45:00