You need to pass the $profileuser->ID as the second argument when you call your function and define it accordingly:
add_filter('wp_handle_upload_prefilter', 'my_pre_upload', 2, 2);
// (3rd param is priority, 4th is number of args)
// and pass the $userid as argument to your function
function my_pre_upload($file, $userid = false){
// if no user specified, get $current_user
$userid = $userid ?: get_current_user_id();
$user = get_userdata( $userid );
$myAuthorImg = 'author-' . $user->ID . '.jpg";
$file['name'] = $myAuthorImg
return $file;
}
Related Posts:
- Set a maximum upload count for users on a specific user role
- How to set custom upload directory per user after moving content directory
- add ‘file upload’ field to user details
- How to allow logged out users to upload media?
- Hide images from anonymous user?
- Edit User Profile From Front End
- How to do action form from functions.php?
- Is there a standard public URL convention used on a WordPress site directly to a page listing all of a user’s public content?
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- How to display a public profile page for registered users with custom slug?
- Create image formats with different qualities when uploading
- Which filters or actions to use after a media upload and delete?
- wp_delete_attachment doesn’t delete images in wp-content/uploads/
- Force WordPress 3.3 to use Flash uploader
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to add more upload directories?
- Multisite, upload images directly to Amazon S3
- How can I speed up a slow loading media library?
- What to do with unattached logos and header uploaded via native wordpress uploader?
- upload_mimes filter has no effect
- Force wordpress to see uploads folder media
- Moving Media Library
- Add item to media library from blob or dataUrl
- How do I enable the customize theme page to accept svg’s?
- Frontend Simple Local Avatar upload
- Disable TinyMCE Drag and Drop
- WP3.5 Media Uploader – how to make it accept multiple images?
- How to define a remote uploads directory?
- Add new media uploader at frontend for wp 3.5+
- Add User meta fields, which only admin can edit
- Incremental number handling on duplicate file names
- Completely hide user info
- Maximum upload size changes in php.ini ignored – How to remove upload size limit?
- Regenerate thumbnails after upload
- How can I default to all WordPress roles when parameter is not included in shortcode?
- Media library storing files in uploads not folders within in uploads
- How to protect media directory with .htaccess?
- Is there a limit on the number of attachments?
- ACF attachment custom field in rest response
- Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?
- media_handle_upload : undefined function?
- Site icons with alpha channel for self-hosted WordPress blog network
- Can I stop wordpress generating media sizes
- Unable to create directory uploads/2018/12. Is its parent directory writable by the server?
- Remove user profile field [duplicate]
- Calling WP Gallery Uploader/Selector From Metabox
- Stop WordPress from generating redundant image size
- WordPress 4.9.8 Trying to add filename over image in Media Browser
- Disable image thumbnails for only one upload folder
- Upload featured image from front end using media-upload.php
- Get File Object from wp.Uploader
- media_handle_sideload on a file already on server
- Capability to prevent upload of files
- wp_handle_upload: get custom checkbox value from media uploader
- HTTP Error When Uploading Images with HTTPS?
- Saving file to disk receiving fopen error
- A link (not in the post) to download a specific PDF file
- Correctly using the root directory for media uploads?
- how to change wp upload directory to another domain directory
- Populate a custom attachment metadata field with data from the image’s EXIF data?
- Disable “Create Audio Playlist” and “Create Video Playlist” in Add Media
- Front-End User Profile
- Change file name on upload in Media Page
- What is the URL pattern for image thumbnails + sizes?
- Setting up a HIPAA secured form / file upload
- How to make picture appear on wordpress site shared link? [closed]
- php return username of currently viewed author profile
- How to download files to WordPress?
- How to detect when a file has been uploaded?
- Extending the user profile [closed]
- Cant upload larger than 100MB
- Generate a QR code when creating a new WordPress user
- PDF Upload from Input Error
- Multiple images are generated in WP-content in wordpress
- Removing extra large generated images disables all crops
- MIME types not recognized by media library
- Missing a temporary folder not fixed
- How can i add user display name drop down menu in frontend?
- How to allow .xls file uploads?
- Updating the attachment from front end doesn’t show the new change
- Allow users to post their videos to my wordpress website?
- wp_update_attachment_metadata breaks after 10 files
- Media URL slugs without uploads folder path
- Add more field on WordPress media upload
- Frontend media shows “An error occurred in the upload. Please try again later.”
- File Upload Management
- update custom field user profile from front end form
- Can i add flickr,imgur etc. up-loader for my WP upload media button?
- Manage user profiles with WordPress
- Files larger than 500 kilobytes are not allowed
- get the post thumbnail returns the full size
- All files unattached in Media Library
- Fetching posts that match a User Profile setting
- Update user from external script
- Media Upload Directory to MMYY instead of YYYY/MM
- Auto-Import of WXR File
- how upload images and videos to specific folder like wp-content\uploads\folder-name
- Media upload takes too long
- Problems with defining UPLOADS constant
- Cant edit profile from frontend