简体   繁体   中英

Get gravity forms input value for address field

How do I get the value of the address input element inside the gform_after_submission hook in Gravity Forms ? I can get values of the other fields with

add_action('gform_after_submission_1', 'post_signup_info', 10, 2);

 function post_signup_info($entry, $form) {
    $name = $entry['1']; //This works
    $address = $entry['2']; //This doesn't.
}

Where name is a text field with id 1, and address is an address field with id 2.

The Gravity Forms documentation says that address fields are represented as an array, but the $address variable in the example above is empty.

How do I access the address field value?

The address field array is stored a bit differently. Try using these values. The example below assumes your address field ID starts with 2.

$street = $entry["2.1"];
$street2 = $entry["2.2"];
$city = $entry["2.3"];
$state = $entry["2.4"];
$zip = $entry["2.5"];
$country = $entry["2.6"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM