That ID is needed when editing the attachment, otherwise it'll break. One thing you could do, save the attachment URL in another custom field. Put the custom field name in the $field_name
variable and another_field_to_save_the_url
will have the attachment URL if any.
[php]
function wpufe_copy_att_url( $post_id ) {
$field_name = ‘my_custom_field_name_in_the_form';
$attach_id = get_post_meta( $post_id, $field_name, true );
if ( $attach_id ) {
$meta_value = wp_get_attachment_url( $attach_id );
update_post_meta( $post_id, ‘another_field_to_save_the_url', $meta_value );
}
}
add_action( ‘wpuf_add_post_after_insert', ‘wpufe_copy_att_url' );
add_action( ‘wpuf_edit_post_after_update', ‘wpufe_copy_att_url' );
[/php]