Home › Forums › Backend Issues (wp-admin) › Rename media on post save › Reply To: Rename media on post save
You cannot rename during the saving of the post. ACF uses the WP native upload. Files and images are uploaded and named when they are added.
I do not have any examples of doing what you want but here is an outline of what would need to be done in ACF to rename the file on upload in ACF
data = acf.applyFilters('prepare_for_ajax', data);
I honestly don’t know how you would rename the files in WP each time the other fields are changed and the post is updated. I have looked and I can’t find much in the way of examples of doing this. If I had to do this I would probably look at the code in other plugins that make it possible to rename a file after it is uploaded and see how they do it and adapt that for use in an acf/save_post action.
This looks somewhat promising https://stackoverflow.com/questions/64990515/wordpress-rename-attachment-file-with-working-thumbnails#answer-65065944
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.