使用 GravityEdit 编辑字段后重新启动重力流工作流程:对于多个表单

问题描述 投票:0回答:1

我有来自 GravityEdit 的代码,它会触发并更新使用用户名编辑重力表格的人。

根据他们的文档,我目前可以放置一张表格。(即表格名称和表格 ID)

`add_filter( 'gravityview-inline-edit/entry-updated', 'gravityedit_custom_who_changed', 10, 5 );

函数gravityedit_custom_who_changed( $update_result, $entry = array(), $form_id = 0, $gf_field = null, $original_entry = array() ) {

if ( 124 !== (int) $form_id ) { // replace 124 with your form ID
    return $update_result;
}

$current_user = wp_get_current_user();
if ( ! ( $current_user instanceof WP_User ) ) {
    return $update_result;
}

$field_id = 3; // replace 3 with the ID of the field you want to store the username

$update_result = GFAPI::update_entry_field( $entry['id'], $field_id, $current_user->user_login );

return $update_result;

}`

任何人都可以协助我如何添加第二个表格,即另一个表格和 ID(例如表格 25 表格 ID 3)?

(我从事营销研发,请原谅我对 PHP 的菜鸟)

谢谢!

当我在functions.php中复制代码时出现“无法重新声明”

php if-statement gravity-forms-plugin
1个回答
0
投票

在“if”语句中,您可以使用||对于逻辑运算符“或”:

'if ( 124 !== (int) $form_id )' 可以改为:

if ( 124 !== (int) $form_id || 25 !== (int) $form_id ){
   return $update_result;
}
© www.soinside.com 2019 - 2024. All rights reserved.