一旦用户提交表单,我将尝试获取字段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;
}发布于 2016-09-08 06:18:45
在第二个函数中重新声明全局变量:
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;
}https://stackoverflow.com/questions/39374579
复制相似问题