wordpress - Getting ACF field value in functions.php -
i try add link file (uploaded in acf field) in gravity form notification, in wordpress.
so, given in gravity form , acf documentation, tried in functions.php add hook 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 id of post int $notification['message'] .= '\n <a href="'.get_field('spec-file', $postid).'">see furniture specs</a>'; return $notification; }
in code above : $postid
works expected (it returns expected post id). thing : get_field('spec-file', $postid)
(which recommended method field value outside loop - http://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/) returns empty.
why ? idea ?
edit : the post id wasn't correct, fixed , code above works expected.
Comments
Post a Comment