Hi again,
I further investigated to pull the data and by combining the wp_get_attachment_url()
with the listing attachment attribute field value to lookup the URL. See the solution below in the filter.
Would you agree this is a solid solution?
add_filter(
'hivepress/v1/forms/booking_confirm',
function($form_args, $form){
$booking = $form->get_model();
if(!$booking){
return $form_args;
}
$listing = $booking->get_listing();
if(!$listing || !$listing->get_put_your_url_attribute_field_name()){
return $form_args;
}
$field_name = 'hp_algemene_voorwaarden'; // replace my_custom_field with the name of your custom field
$attachment_post_id = $listing->get_algemene_voorwaarden();
$attachment_url = wp_get_attachment_url( $attachment_post_id );
echo $attachment_url;
if(isset($form_args['fields']['algemene_voorwaarden'])){
$form_args['fields']['algemene_voorwaarden']['description'] = '<a href="'.esc_url($attachment_url).'" target="_blank" rel="noopener">Custom text</a>';
}
return $form_args;
},
1000,
2