Home › Toolset Professional Support › [Resolved] i want to hide Uploaded Files in the media Library
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 1 reply, has 1 voice.
Last updated by Minesh 3 weeks, 2 days ago.
Assisted by: Minesh.
Hello Toolset Team,
We have changed the upload path for files to wp-content/bewerbungsunterlagen. The files are being saved in the correct folder as intended. However, we would like to prevent these files from appearing in the WordPress media library.
we used this code:
function custom_upload_dir($uploads) {
// Pruefen, ob ein Post ID gesetzt ist
if (isset($_REQUEST['post_type'])) {
$post_type = $_REQUEST['post_type'];
// Debugging: Post Type pruefen
error_log('Detected Post Type: ' . $post_type);
if ($post_type == 'bewerbung') {
error_log('Custom upload_dir for bewerbungen is running.');
$custom_dir = WP_CONTENT_DIR . '/bewerbungsunterlagen';
$custom_url = content_url('/bewerbungsunterlagen');
// pruefen, ob das Verzeichnis existiert, und erstellen, wenn nicht
if (!file_exists($custom_dir)) {
mkdir($custom_dir, 0755, true);
}
$uploads['path'] = $custom_dir;
$uploads['subdir'] = ''; // Kein Unterverzeichnis
$uploads['basedir'] = $custom_dir;
$uploads['baseurl'] = $custom_url;
$uploads['url'] = $custom_url;
}
}
return $uploads;
}
add_filter('upload_dir', 'custom_upload_dir', 101, 2);
Could you please assist us in achieving this?
Best regards,
KlausB
Hello. Thank you for contacting the Toolset support.
There is no such feature available and it is pure custom code.
However - you should try to find such plugin that should help you in this matter:
- hidden link
- https://wordpress.stackexchange.com/questions/56456/limit-media-library-to-given-folder
- https://wordpress.stackexchange.com/questions/377365/prevent-a-folder-from-being-shown-within-the-media-library
- https://wordpress.org/plugins/media-library-plus/