mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Update 1.0.58
This commit is contained in:
@@ -6,16 +6,21 @@
|
||||
add_action('um_after_user_upload','um_remove_unused_uploads', 10);
|
||||
function um_remove_unused_uploads( $user_id ) {
|
||||
global $ultimatemember;
|
||||
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
$array = $ultimatemember->user->profile;
|
||||
|
||||
|
||||
$files = glob( um_user_uploads_dir() . '*', GLOB_BRACE);
|
||||
foreach($files as $file) {
|
||||
$str = basename($file);
|
||||
if ( !strstr( $str, 'profile_photo') && !strstr( $str, 'cover_photo') && !preg_grep('/' . $str . '/', $array ) )
|
||||
unlink( $file );
|
||||
|
||||
if ( file_exists( um_user_uploads_dir() ) && $files && isset( $array ) && is_array( $array ) ) {
|
||||
|
||||
foreach($files as $file) {
|
||||
$str = basename($file);
|
||||
if ( !strstr( $str, 'profile_photo') && !strstr( $str, 'cover_photo') && !preg_grep('/' . $str . '/', $array ) )
|
||||
unlink( $file );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user