Title: Prepopulate fields
Last modified: January 27, 2017

---

# Prepopulate fields

 *  Resolved [fuchsws](https://wordpress.org/support/users/fuchsws/)
 * (@fuchsws)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/prepopulate-fields/)
 * I would like to define “placeholders” in the default_value field which dynamically
   populate field values.
 * So for example a field “company name” should be filled in with the user meta “
   company_name”. For this I could think about using the default_value for this 
   field like “%%usermeta:company_name%%”.
 * A custom functions then hooks into “acf/render_field” and replaces the “$field[‘
   value’]” with “get_user_meta(get_current_user_id(), ‘company_name’, true)” and
   clears the default_value.
 * But, this is not working. The input value just stays empty.
    I’ve increased the
   priority of the action to max but still empty. It seems this hook doesn’t apply
   with acf_get_fields() your are using.
 * hmmm, what am I missing here?

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

 *  Thread Starter [fuchsws](https://wordpress.org/support/users/fuchsws/)
 * (@fuchsws)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/prepopulate-fields/#post-8720398)
 * figured it out (I used the wrong hook):
 *     ```
       function my_acf_load_field( $field )
       {
           if ( strpos($field['default_value'], '%%') === 0 )
           {
               $default_values = explode(':', str_replace('%%', '', $field['default_value']));
               if ( $default_values[0] == 'usermeta' )
                   $field['value'] = get_user_meta(get_current_user_id(), $default_values[1], true);
           }
           return $field;
       }
       add_filter('acf/load_field', 'my_acf_load_field');
       ```
   
    -  This reply was modified 9 years, 4 months ago by [fuchsws](https://wordpress.org/support/users/fuchsws/).
 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/prepopulate-fields/#post-8722175)
 * Great that you managed to work it out! I’m sorry for the late reply.
 * If you have any other questions or problems in the future I would love to help.
   Just create a support thread. 🙂
 * Good luck!

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

The topic ‘Prepopulate fields’ is closed to new replies.

 * ![](https://ps.w.org/advanced-forms/assets/icon-256x256.png?rev=1894254)
 * [Advanced Forms for ACF](https://wordpress.org/plugins/advanced-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-forms/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/prepopulate-fields/#post-8722175)
 * Status: resolved