There must be something identifiable about your form data, such as your input names. Check for one or more of those and process accordingly.
function custom_upload_dir($args) {
if (isset($_POST['something'])) {
$args['path'] = $args['basedir'] . "/mypath" . $args['subdir'];
$args['url'] = $args['baseurl'] . "/mypath" . $args['subdir'];
}
return $args;
}
After some investigation, the only things I see that might help are …
- The post ID is passed through the
POST
data to the callback.
However I don’t know this would be set to in you custom plugin page. $_SERVER['HTTP_REFERER']
appears to be set correctly. You could
parse that to determine if your plugin page is the originating
page.
If I had the full plugin source I could do some testing.
Related Posts:
- How can I add an image upload field directly to a custom write panel?
- Checking if a file is already in the Media Library
- Standard location for plugin to save/cache files?
- Saving data-URI to media library
- Can I use the wp media uploader for my own plugin?
- Change Media Uploader default directory
- Changing upload directory for plugin uploads only
- Upload file to remote storage
- Why are two functions over-riding each other?
- WordPress Media mime type filter problem 4.0
- Using the component outside the editor. select(‘core’) is null
- Proper way to hook wp_get_attachment_url
- Getting Details Of Uploaded Image
- Sharing a common set of image files for media library, across all sites within multisite
- Uploading images from a custom page using blueimp uploader?
- Hook to get image filename when it is uploaded
- How to send email in wordpress with more than one attachments
- Using the default wordpress uploader inside plugin
- Files automatically added
- What filter should I use to insert a button inside on Media>Add New
- Changing upload dir in a plugin regardless of post type
- How to replicate Media Library “Add New” on Plugin Settings Page
- Plugin writing: access file that was just uploaded
- Custom delete option button in plugin settings
- How to enable sorting in custom media uploader in plugin
- Create a new post using rest api and save featured image using an external image url
- Why is the temporary upload always 4.1K
- Upload multiple images and insert them into custom html code
- wp_editor add media button not working
- WordPress Specified file failed upload test
- How to create a digital product download link that can’t be used twice?
- How to submit/upload data to database and in specific folder?
- Cleaning a filename after image sideloading a url that contains `%20`
- Get audio metadata on file upload
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- Why doesn’t update_post_meta work for certain strings?
- wp.media Uncaught TypeError: Cannot read properties of undefined (reading ‘state’)
- Insert and read media from the WordPress library and call in the plugin
- Trying to rename a file upload as the hash of file content on wordpress
- Home page is not loading, where in other pages are displaying on the site
- WordPress5.2.3: Better File Download Plugin validation issue
- WordPress discards PNG file when uploading plugin file
- Hook for validating and rejecting frontend image upload
- Changed media upload path for plugin, but generates error & shows wrong url
- How to destroy or dispose wordpress uploder/manager?
- Displaying $_FILES data (simlar to $_POST)
- How do you filter get_media_items by mime type in a custom media upload tab?
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- upload script in plugin development [duplicate]
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- Upload to a specific media folder created by FileBird Lite
- Load images from CDN and custom features to “Add Media” dialogue
- upload image to wordpress media library failed for custom post type
- How can I add an option to the Page Template list from a Plugin?
- Using composer for dependency management in plugindevelopment
- add_filter and remove_filter added before and after wp_query
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- How can I hook into existing WordPress Bulk actions?
- Scheduled event does not run at midnight
- creating elements/innerblocks via rangecontrol
- How to check if current static page is frontpage from admin plugin
- Woocommerce add custom button to backend order table
- Earliest WP Hook to Safely and Reliably Redirect
- What is rich_editing?
- How Can I setup WP CLI on Windows development machine running AMPPS?
- Is it possible to delay execution of shortcode output callback?
- wp_enqueue_script + wp_enqueue_style Since When
- Which themes do you use to test compatibilities with your plugin [closed]
- How to debug a unit test for a WordPress plugin, which uses wordpress-test?
- Is there any way to allow a plugin to write over a previous version?
- How do i validate data entered in a meta box so that only floats can be entered in a field?
- get_current_screen() return null
- Tried in different ways but sidebar not working?
- How to run a function on plugin’s options page?
- What stylesheets are available in core?
- Theme Install using a Custom Repository
- Activate User in Code (BuddyPress+bbpress)
- Search: how to extend the existing search to include a custom table
- Plugin development: delete options when updating to a new version
- Custom code for WordPress dynamic menu
- Can’t change the style of a submit input type? [closed]
- How to get all queries’s results after they have executed?
- why update option is not working?
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- How add default term meta to prevent an error?
- Plugin admin page stylesheet doesn’t work
- 403 error rest_’cookie_invalid_nonce’ on API Request
- Insert, update or remove data from database (usermeta)
- AJAX call of function containing javascript which is not loaded (Plugin development)
- Filterable posts using categories
- How do I make two shortcode use the same id and increment it when I use them multiple times?
- How to CRUD from wordpress database in wordpress theme?
- Can a plugin differentiate syndication feeds from actual site views?
- Plugin settings checkbox
- Change Admin menu placement using hooks
- Adding querystring variable breaks admin URLs
- Saving multiple fields as array
- I don’t understand how symlinks in plugin work
- Undo operation not working in Rich text [Gutenberg]
- Saving metabox updates causing fatal error