我已经测试了我的自定义函数,当提供表单id和条目id时,该函数本身就可以正常工作。但是在提交表单时,它似乎永远不会触发。
我正在使用动作add_action( 'gform_after_submission_14', 'after_submission', 10, 2 );
我的表格id是14。
如何对此问题进行故障排除或更正?
我的代码是:
add_action( 'gform_after_submission_14', 'after_submission', 10, 2 );
function after_submission($entry, $form){
global $wpdb;
include $_SERVER['DOCUMENT_ROOT'] . '/custom_config.php';
$data = RGFormsModel::get_lead($entry);
$eid = $data['id'];
$user_id = $data['created_by'];
$hotel = $data['33'];
$flight = $data['39'];
$car = $data['38'];
$parking = $data['37'];
$entertainment = $data['36'];
$other = $data['35'];
if($hotel!=''):
mysqli_query($link,"INSERT INTO reimbursements ( user_id, eid, amount, type ) VALUES ( '$user_id', '$eid', '$hotel', 'hotel' )");
print_r($link);
endif;
if($flight!=''):
mysqli_query($link,"INSERT INTO reimbursements ( user_id, eid, amount, type ) VALUES ( '$user_id', '$eid', '$flight', 'flight' )");
endif;
if($car!=''):
mysqli_query($link,"INSERT INTO reimbursements ( user_id, eid, amount, type ) VALUES ( '$user_id', '$eid', '$car', 'car' )");
endif;
if($parking!=''):
mysqli_query($link,"INSERT INTO reimbursements ( user_id, eid, amount, type ) VALUES ( '$user_id', '$eid', '$parking', 'parking' )");
endif;
if($entertainment!=''):
mysqli_query($link,"INSERT INTO reimbursements ( user_id, eid, amount, type ) VALUES ( '$user_id', '$eid', '$entertainment', 'entertainment' )");
endif;
if($other!=''):
mysqli_query($link,"INSERT INTO reimbursements ( user_id, eid, amount, type ) VALUES ( '$user_id', '$eid', '$other', 'other' )");
endif;
mysqli_close($link);
}发布于 2021-01-12 08:14:30
问题出在这里:
$data = RGFormsModel::get_lead($entry);
$entry已是正在使用的数组。
因此,我应该使用:$eid = $entry['id'];来定义它们,而不是像我那样再次定义它们:$eid = $data['id'];
这个解决方案的更大部分是找出解决问题的能力。
为此,我做了以下工作:
如此处所述,在' Forms ->Settings-> logging‘中添加’function.
GFCommon::log_debug( __METHOD__ . '(): running.' );添加到https://stackoverflow.com/questions/65673163
复制相似问题