Hi again @jordan141431
I just got a reply back from one of our developers, and it turns out this is simpler than I thought. ??
The code below is an example of how to populate a text input field with the post title from a specified post ID.
<?php
add_filter( 'forminator_field_text_markup', function( $html, $field ) {
$post_id = 1;
$post = get_post( $post_id );
if ( 'text-1' === $field['element_id']) {
$html = str_replace( 'value="post_populate"', 'value="' . $post->post_title . '"', $html );
}
return $html;
}, 10, 2 );
In this example, the post_id we’re fetching data from = 1, and the element_id of the form field we’re populating = text-1.
The code will check if a default value of post_populate is set in any text-1 field, and replace it with the post_title of the specified post_id. If it doesn’t find that default value in any such text field, it won’t do anything.
Please do let us know if this is what you’re looking for, or if you need further help with this.
Cheers!
Patrick