0
votes

Once a user submits the form, I am trying to grab the data in field 1, assign it to a variable and then in a different function I am trying to use that data.

The data is successfully going into the variable defined in the after_submission function as I was able to simply tell the site to break if a certain word was in the variable. It's now a matter of getting that same data from a different function.

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;
}
1

1 Answers

0
votes

Redeclare the global variable in your second function:

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;
}