Last active
December 13, 2019 07:52
-
-
Save tripflex/95925fc065ee40fead1c7d03204e9498 to your computer and use it in GitHub Desktop.
Prepend username on any files uploaded with WP Job Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'job_manager_upload_file_pre_upload', 'smyles_add_user_login_to_file_uploads' ); | |
function smyles_add_user_login_to_file_uploads( $file ) { | |
$user = wp_get_current_user(); | |
if ( $user && $user->ID > 0 ) { | |
$file['name'] = sanitize_file_name( $user->user_login ) . '_' . $file['name']; | |
} | |
return $file; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment