Hi there,
I’m building an invoice system using ACF. Selecting a user to send the invoice to is fine and dandy. But I’d like to autopopulate the next field with the email address of the selected user. How can I do this?
Thanks in advance.
~Laura
How are you at jQuery? I created an example of how to do something similar using 2 select fields. https://support.advancedcustomfields.com/forums/topic/auto-populate-field-with-user-data/
I’m a novice at jQuery, I’m afraid. I’m trying to learn it, but it’s slow going for me.
There would be three main differences between my example and what you want to do that would take some testing and playing.
1) Getting the value of the field were you select the user, assuming that you’re using a user field.
2) How you populate the email field, assuming you’ll be wanting to use an email field
3) The php function that gets and returns the email will need to look at users instead of posts.
If I have some time in the next few days I’ll try to take a look at it.
I have created a new example that shows how to populate some text based fields based on the selection made in a user field https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-text-based-on-user-select.
Enjoy!
~JH
I’ll have to keep working on this. Thank you! Question: How do I import a json file? the WordPress importer won’t let me do this for some reason 🙁 (note: this site doesn’t have the pro version of ACF)
Only if you want to test the example, the JSON file is an export created by ACF and can be imported with ACF5. The example I created is for ACF5 and it won’t work in ACF4. The JS in ACF4 is different and not as easily extended.
I keep forgetting that not everyone is using ACF5