Passer la navigation

[Résolu] i want to hide Uploaded Files in the media Library

This support ticket is created Il y a 7 mois et 3 semaines. There's a good chance that you are reading advice that it now obsolete.

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 -

Fuseau horaire du supporter : Asia/Kolkata (GMT+05:30)

Ce sujet contient 1 réponse, a 1 voix.

Dernière mise à jour par Minesh Il y a 7 mois et 2 semaines.

Assisté par: Minesh.

Auteur
Publications
#2786261

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

#2786478

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

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:
- lien caché
- 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/