dqlxtv1452 2018-07-11 11:12
浏览 8

仅在某个特定字段更新时添加注释

On the admin side of Gravity form, I want to add a note if an admin user changes the status of the form entry. I have an admin only field so that bit is working and I know how to add note.

But can't work out, how to add note only if a certain field is changed. I need it to say something like 'status was updated from "approved" to "closed" by xxx'

Any help would be much appreciated.

Thanks.

add_action( 'gform_after_update_entry', function ( $form, $entry_id ) {

    $current_user = wp_get_current_user();
    $note = 'status updated from' . $status_from . ' to ' . $status_to . ' by ' . $current_user;
    RGFormsModel::add_note( $entry_id, $current_user->ID, $current_user->display_name, $not );
}, 10, 2 );
  • 写回答

1条回答 默认 最新

  • droc60607 2018-07-11 14:07
    关注

    Worked it out. For anyone who may need it. Answer below :)

    add_action( 'gform_after_update_entry', 'update_entry', 10, 3 );
    function update_entry( $form, $id, $original ) {
    
        $entry = GFAPI::get_entry( $id );
    
        $status_from = $original[ID_OF_THE_FIELD];
        $status_to = $entry[ID_OF_THE_FIELD];
    
        if($status_from != $status_to) {
            $current_user = wp_get_current_user();
            $message = 'Status updated from ' . $status_from . ' to ' . $status_to . ' by ' . $current_user->display_name;
            RGFormsModel::add_note( $entry_id, $current_user->ID, $current_user->display_name, $message );
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?