custom upload directory only for plugin uploads

i’m trying to add an upload_dir filter only for plugin-uploads. does anybody know why the code below doesn’t work, and what could work instead? thanks in advance!

$upload_dir = 'publications';
$plugin_dir = WP_CONTENT_DIR ;
$plugin_url = WP_CONTENT_URL ;

add_filter('upload_dir', 'custom_upload_dir');

function custom_upload_dir($path_data){
global $upload_dir;
global $plugin_dir;
global $plugin_url;

if ( $_GET['page'] == 'teachpress/addpublications.php'){
    $path_data['path'] = $plugin_dir . "/" . $upload_dir;
    $path_data['url'] = $plugin_url . "/" . $upload_dir;
    $path_data['subdir'] = "/" . $upload_dir;
    $path_data['basedir'] = $plugin_dir;
    $path_data['baseurl'] = $plugin_url;
    }
return $path_data;
}

Related posts

Leave a Reply