Use something like this function, you need to set condition for if(user==admin) and then if(post-type==’some-post-type’):
function wpse_16722_type_upload_dir( $args ) {
// Get the current post_id
$id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : '' );
if( $id ) {
// Set the new path depends on current post_type
$newdir="https://wordpress.stackexchange.com/" . get_post_type( $id );
$args['path'] = str_replace( $args['subdir'], '', $args['path'] ); //remove default subdir
$args['url'] = str_replace( $args['subdir'], '', $args['url'] );
$args['subdir'] = $newdir;
$args['path'] .= $newdir;
$args['url'] .= $newdir;
}
return $args;
}
add_filter( 'upload_dir', 'wpse_16722_type_upload_dir' );
Related Posts:
- Uploading media with the REST API
- Decrease file size upload in Media
- Adding a custom image upload size and making it selected by default?
- Failed media upload: “The uploaded file was only partially uploaded.”
- How to upload imagick resource to media in wordpress
- Upload images and attachments from frontend form
- WordPress media upload “HTTP error”
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- How do I get around “Sorry, this file type is not permitted for security reasons”?
- WordPress automatically adds links to uploaded images
- Get featured image with custom size outside WordPress
- Convert all uploaded PNG files to PNG-8 format
- How to decrease the max file upload size without using php.ini or htaccess?
- Hook on file upload
- wp_delete_attachment not working with multiple values
- Can’t upload files
- Edit Image/Image Details – Replace button missing
- How to automatically convert images to WebP on WordPress?
- How to make a image-size selected by default in Media upload – WP v3.5
- How to change upload directory in wp_handle_upload
- Hide old attachments from wp media library
- Image Upload “exceeds the maximum upload size for this site”, but php.ini is correct
- How to register images uploaded via FTP in media library?
- Create Image Uploader for Widget
- PHP/Manual use of images? – 2 Questions
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Modify image while uploading
- Debugging upload problem: What part of WP does actual image-resizing?
- How to resize image on client-side before upload?
- Add custom image sizes to media uploader
- Accessing a random image via ajax
- Make WordPress upload directory outside wordpress root with custom url
- Is it unsafe to put php in the /wp-content/uploads directory?
- Adding featured image via PHP
- How to enlarge the media file upload size in wordpress admin
- How do I get images (with a thumbnail preview) to show in search results?
- Restrict WordPress File Type Uploads by User Type
- File upload, uploads only file name
- Modify Maximum upload file size text
- Upload a json file in php [closed]
- Custom image upload
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Memory errors with media upload, WordPress can’t use more than 96M (while there’s 512 available!)
- Get most recent media upload
- Convert all images to PNG on file upload
- Upload Image in a WordPress page using PHP
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- how to retrieve uploaded url of zip files
- Why is $_REQUEST an empty array in admin-ajax.php?
- How do you use WP slugs for PDF files / media?
- Need help with Google drive API [closed]
- Image rotation and editing stopped working in WordPress after upgrading Ubuntu from 16.04 to 18.04
- Upload file could not be moved to wp-content/uploads
- Change WordPress Upload Folder using wp handle upload
- How do I Import / Upload Files with jQuery AJAX?
- Returning data instead of echoing/printing
- Blob file download problem
- zip unzip attachments in wordpress
- WordPress get_media_embedded
- WordPress upload file size error even after raising php limits
- Get uploaded image and attach it to the new post
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Images Uploaded saving onto older/previous year folders
- Convert canvas to image and upload image to server
- How to get the filename from file system and create a download link?
- custom plugin with upload files does not work
- How to Make Thumbnail of Post Stay Animated
- Hide media for non logged in users
- Some problems in custom widget
- Checking page before applying image restrictions while uploading
- Change image data durgin upload
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Change upload URL by mime type
- I want url from a file in media using title file
- Crop an image after upload on custom account page
- media_handle_upload fails with gravity form submitted image
- Restrict File Type Uploads by User on Wordress via functions.php
- Renaming “Expand Details” within “Add Media”
- Get posts associated with media attachment
- Save the outputted image into the Media Library, with a different filename and extension
- File path for attachments outside of wp-content/uploads
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Name Input from widget displays Sidebar name instead of saved data
- show/hide attachments
- File Upload with Server in safe_mode
- Correct Syntax for uploading files to custom directory in WordPress
- Generate and upload screenshot as featured image for user-submitted post
- Pull latest Youtube Video from json url and make new post
- WordPress directories not writable after PHP version upgrade
- Upload multiple files via ajax from an HTML file input
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- stop resize button for wordpress media
- “Unexpected response from server” error when trying to upload any .mp4 file over 100MB
- Get a list of folders inside uploads directory
- Changing upload directory temporarily
- How can we upload custom page files?
- Unable to upload media to WordPress