I try to add a link to a file (uploaded in ACF field) in a Gravity form notification, in WordPress.
So, as given in Gravity form and ACF documentation, I tried in my functions.php to add a hook to the gravity form notification mail function :
add_filter( 'gform_notification_1', 'my_gform_add_link', 10, 3 );
function my_gform_add_link( $notification, $form, $entry ) {
$postID = intval($entry[2]); //return the ID of the post as an int
$notification['message'] .= 'n <a href="'.get_field('spec-file', $postID).'">See this furniture specs</a>';
return $notification;
}
In the code above : $postID
works as expected (it returns the expected post ID). The thing is : get_field('spec-file', $postID)
(which is the recommended method to get a field value outside the loop – http://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/) returns empty.
Why ? Any idea ?
EDIT : The post ID wasn’t correct, I fixed it and the code above works as expected.