Home › Forums › General Issues › Custom User Photo Field › Reply To: Custom User Photo Field
So, this is what I would do, and this is because it’s only something that I’d need to use once. I’d build a php script that connected directly to the WP database.
Search the user table and get the list of users and needed user data
Loop through each user and construct a string to use to look for the image
search the post table column guid
or post_name
LIKE %$name_value%
and get the ID of the attachement
Each record for and ACF field requires two entries in the usermeta table
INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES ("$user_id", "$acf_field_name", "$post_id"), ("$user_id", "_$acf_field_name", "$acf_field_key")
I’d do some testing with one or two users to make sure it works and delete anything it added so you don’t get duplicates. Make sure you back up the database. Then I’d set it up to run as a cron job because this will likely timeout if you try to run it in a browser.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.