Home › Forums › General Issues › modify field on post save › Reply To: modify field on post save
You’re URL is going to be different dependent on if they use the “URL” from the browser bar or the URL from the “Share” feature on youtube. Parsing out the id will require accounting for all possibilities.
A URL field must have a valid URL, only a text field would work for holding just the video ID, so you cannot modify a URL field to hold just the video ID. If you did this then then the field may be blank when the admin reloads and if not it would create a validation error on the next save.
Updating one field based on another field is as simple as using an acf/save_post action that gets the value from the URL field, parses out the video id and then use update_field() to update the other field.
I would not do this, instead I would create and acf/format_value filter with a priority > 10 to run after ACF and I would parse out the video id in and return it in this filter.
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.