重力形式 (WP):来自 after_submission 的全局变量
Gravity Forms (WP): global variable from after_submission
用户提交表单后,我会尝试获取字段 1 中的数据,将其分配给一个变量,然后在另一个函数中尝试使用该数据。
数据已成功进入 after_submission 函数中定义的变量,因为如果某个单词在变量中,我可以简单地告诉站点中断。现在的问题是从不同的函数获取相同的数据。
add_action("gform_after_submission", "after_submission", 10, 1);
function after_submission($entry, $form){
$shopname = $entry["1"];
global $response;
$response = 'https://openapi.etsy.com/v2/shops/'. $shopname .'/listings/active?api_key=xxxxxxxxxxxxx )';
}
function dynamic_url(){
$apiurl = $response;
return $apiurl;
}
在第二个函数中重新声明全局变量:
add_action("gform_after_submission", "after_submission", 10, 1);
function after_submission($entry, $form){
$shopname = $entry["1"];
global $response;
$response = 'https://openapi.etsy.com/v2/shops/'. $shopname .'/listings/active?api_key=xxxxxxxxxxxxx )';
}
function dynamic_url(){
global $response;
$apiurl = $response;
return $apiurl;
}
用户提交表单后,我会尝试获取字段 1 中的数据,将其分配给一个变量,然后在另一个函数中尝试使用该数据。
数据已成功进入 after_submission 函数中定义的变量,因为如果某个单词在变量中,我可以简单地告诉站点中断。现在的问题是从不同的函数获取相同的数据。
add_action("gform_after_submission", "after_submission", 10, 1);
function after_submission($entry, $form){
$shopname = $entry["1"];
global $response;
$response = 'https://openapi.etsy.com/v2/shops/'. $shopname .'/listings/active?api_key=xxxxxxxxxxxxx )';
}
function dynamic_url(){
$apiurl = $response;
return $apiurl;
}
在第二个函数中重新声明全局变量:
add_action("gform_after_submission", "after_submission", 10, 1);
function after_submission($entry, $form){
$shopname = $entry["1"];
global $response;
$response = 'https://openapi.etsy.com/v2/shops/'. $shopname .'/listings/active?api_key=xxxxxxxxxxxxx )';
}
function dynamic_url(){
global $response;
$apiurl = $response;
return $apiurl;
}