Support

Account

Home Forums Backend Issues (wp-admin) Removing Attachment post_parent on File Field Type

Solved

Removing Attachment post_parent on File Field Type

  • I have a Repeater Field which allows a user to upload up to three Files using the File Field Type. This works fine, and allows me to upload up to three files.

    The problem is that when editing a post, if I upload a file into the repeater field, and then later remove this same file, it remains associated in the wp_posts table with its post_parent set to the ID of the post it was uploaded to.

    For my specific use in this site, I would like to remove this association (i.e., set the post_parent = 0 for the attachment) whenever a file is removed from a post repeater field. Alternatively, I’d like to delete the file all together if it is removed from the post; I can’t count on my users to clean up the files they upload but decide not to use.

    What hook can I use to alter this functionality?

  • I was able to get around the issue I’d encountered by simply only referring to files actually being saved to the post, instead of files associated with the post.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Removing Attachment post_parent on File Field Type’ is closed to new replies.