【问题标题】:Add Note only if a certain certain field gets updated仅当某个特定字段得到更新时才添加注释
【发布时间】:2018-12-19 09:51:23
【问题描述】:

在 Gravity 表单的管理员端,如果管理员用户更改表单条目的状态,我想添加注释。我有一个仅限管理员的字段,因此该位正在工作,并且我知道如何添加注释。

但无法解决,如何仅在更改某个字段时添加注释。我需要它说“状态已由 xxx 更新为“已批准”为“关闭”之类的内容

任何帮助将不胜感激。

谢谢。

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

【问题讨论】:

    标签: php gravity-forms-plugin gravityforms


    【解决方案1】:

    解决了。对于任何可能需要它的人。在下面回答:)

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多