php - Wordpress: change upload dir conditionally -


for theme i'm creating need possibility upload images through theme-settings page. no problem far. images uploaded through specific settings page should stored in different dir standerd upload dir, or @ least have make them different 'other' media.

i did find nice script change upload dir:

function ml_media_upload_dir($upload) { global $user_id; if ((int)$user_id > 0) {     $upload['subdir'] = "/" . $user_id.'test'.$id;     $upload['path'] .= $upload['subdir'];     $upload['url'] .= $upload['subdir']; }  return $upload; } add_filter('upload_dir', 'ml_media_upload_dir'); 

by now, upload dir changed specific user_id. change dir when media uploader fired specific theme-options page. see screenshot below.

would great comments on how handle this; after searching hours , hours still haven't found solution.

screenshot

i think 1 solution (temporarily) overwrite core function filter. add filter before upload initiated on custom page, , possibly remove filter again once it's done.

not tested. luck!


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -