在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 );
答案 0 :(得分:0)
解决了。对于任何可能需要它的人。回答如下:)
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 );
}
}