Title: Autofill ACF Fields
Last modified: August 3, 2023

---

# Autofill ACF Fields

 *  Resolved [iceman3333](https://wordpress.org/support/users/iceman3333/)
 * (@iceman3333)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/autofill-acf-fields/)
 * Hello, I need help.
 * I have created a form. For this, it would be good if I could retrieve the data
   from the user profile. And fill it automatically.
   I have an ACF field under user
   that has the name “member number” this number is very important when ordering
   and should be automatically entered into form. Have unfortunately nothing in 
   the description nothing found how I must design the query.
 * Can you please help me how to do this.
   Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [Nithin – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport11/)
 * (@wpmudevsupport11)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/autofill-acf-fields/#post-16944382)
 * Hi [@iceman3333](https://wordpress.org/support/users/iceman3333/),
 * I’m afraid, there isn’t any out-of-the-box setting for such a workflow. However,
   this should be possible using custom code.
 * I’m checking with our developer regarding this to see if we could provide a workaround.
 * Will keep you posted once we get further feedback asap.
 * Kind Regards,
 * Nithin
 *  Plugin Support [Nithin – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport11/)
 * (@wpmudevsupport11)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/autofill-acf-fields/#post-16944440)
 * Hi [@iceman3333](https://wordpress.org/support/users/iceman3333/),
 * Could you please try this snippet and see whether it helps:
 *     ```wp-block-code
       <?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](https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins)
 * Kind Regards,
 * Nithin
   `
 *  Thread Starter [iceman3333](https://wordpress.org/support/users/iceman3333/)
 * (@iceman3333)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/autofill-acf-fields/#post-16944558)
 * Thanks for the help, thought this might be easier. I have to find a simpler solution.
 * You can close the request

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Autofill ACF Fields’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [iceman3333](https://wordpress.org/support/users/iceman3333/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/autofill-acf-fields/#post-16944558)
 * Status: resolved