Hi @iceman3333,
Could you please try this snippet and see whether it helps:
<?php
add_action( 'forminator_before_form_render', 'wpmudev_number_field_value_form', 10, 5 );
function wpmudev_number_field_value_form( $id, $form_type, $post_id, $form_fields, $form_settings ) {
if ( 943 == $id ) {
add_filter( 'forminator_field_number_markup', 'wpmudev_add_value_field_cpt', 10, 5 );
}
}
function wpmudev_add_value_field_cpt( $html, $id, $required, $placeholder, $value ) {
$meta_val = '';
if ( strpos( $id, 'forminator-field-number-1' ) !== false ) {
$meta_val = get_post_meta( get_the_ID(), 'member_number', true );
$html = str_replace( 'name="number-1"', 'name="number-1" value="'.$meta_val.'"', $html );
}
return $html;
}
The above snippet is only meant to auto fill a Number field in the form with an ACF field.
Where 943 in the above code is a form ID and would recommend you to replace that with your form ID.
In the given code, the number-1
should be changed to your Number fields ID in your form. The member_number
in above code needs to be replaced with the ACF custom field name.
You can apply the above code as a mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Kind Regards,
Nithin
`