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.