I have to run some code <b>after an image is inserted into media library</b> (so after a post of an attachment
post type is save) but <b>before thumbnails are generated</b>. I also need to know what ACF field has triggered the upload because I have to save the ACF key into attachment meta (don’t ask why, please ;)).
So, in order to do that, I can’t rely on any ACF hook (no, I can’t use the acf/upload_prefilter
hook because at this stage an attachment doesn’t exist yet), but I can use a WordPress add_attachment
hook.
That’s good, but as it’s a WordPress hook, not an ACF hook, I do not have an access to the ACF field key through the filter parameters. But I do have an access to the ACF field kay through PHP $_POST
global:
$acfFieldKey = filter_input(INPUT_POST, '_acfuploader', FILTER_SANITIZE_STRING);
Nice, it solves my problem, but can I really rely on the _acfuploader
variable? It’s not a part of the ACF API, so I’m afraid that this value might change in future and this change will not be documented.
Is it very likely that this value will change?