I have a Staff Contact form which should be populated with ACF data. The post\_id is passed to the form by a query string (‘…/contact-form/?post\_id=99999’), and I can populate a field with the post\_id by simply adding ‘post\_id’ to populate dynamically under the field’s advanced settings.
However, I can’t figure out how to get the ACF data into the other form fields.
I did successfully set up a short code which populates a greeting with the name at the top of the page – above the form.
add_shortcode (‘full_name’, ‘getName’);
function getName(){
$post_id = get_query_var(‘post_id’);
$full_name = get_field( “full_name”, $post_id );
return “<h3>Send message to “. $full_name . “</h3>”;
}
I feel like I’m missing something obvious, but I’ve been banging away at this for 2 days.
[ad_2]