Skip to content

Instantly share code, notes, and snippets.

@anthonysbrown
Created December 3, 2021 14:31
Show Gist options
  • Save anthonysbrown/ce5e2ecdd009bb02f255180c736323f4 to your computer and use it in GitHub Desktop.
Save anthonysbrown/ce5e2ecdd009bb02f255180c736323f4 to your computer and use it in GitHub Desktop.
Do something after file upload
<?php
/*
$target_path= full path of uploaded file (not yet inserted into db)
$uid = the ID of the user uploading the file
*/
add_action('sp_cdm_after_file_upload','my_file_insert',10,3);
function my_file_insert($target_path,$uid){
if(my_custom_check_file($target_path) == false){
unlink($target_path);
die('{"OK": 0, "info": "File did not pass my custom check"}');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment