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.