Ondersteuning » Algemeen WordPress » Beheer afbeeldingen in media library

  • Ik wil dat users hun eigen afbeeldingen kunnen uploaden en beheren. In de media library staan echter alle afbeeldingen van alle users.

    Hoe kan ik de afbeeldingen zo filteren dat een user alleen zijn/haar eigen afbeeldingen kan zien en niet de media van andere gebruikers?

    Alvast dank voor hulp!

7 reacties aan het bekijken - 1 tot 7 (van in totaal 7)
  • Thread starter aw2

    (@aw2)

    Dank valandil!
    Je link is mooi maar niet helemaal wat ik zoek.

    Ik heb verschillende contributors die afbeeldingen plaatsen.
    De contributors moeten alleen hun eigen afbeeldingen kunnen beheren. Ze mogen dus alleen hun eigen afbeeldingen kunnen zien in de media library en niet die van andere contributors.
    Alle afbeeldingen en media die niet van de Contributor zelf is moet niet zichtbaar zijn in de Media Library.

    Dank!

    Dan word het vermoedleijk een lastige die je denk ik deels zelf moet (laten) maken, of even goed ozeken tussen de plugins, deze kwam naar mijn idee vrij dichtbij.

    Thread starter aw2

    (@aw2)

    Easy albums is zeker een mooie plugin.

    Ik ben hier wel dit tegengekomen wat zou moeten doen wat ik nodig heb.
    Het is me alleen nog niet gelukt om het werkend te krijgen…

    You could always filter the media list using a pre_get_posts filter that first determines the page, and the capabilities of the user, and sets the author parameter when certain conditions are met..

    Example
    ________________

    add_action('pre_get_posts','users_own_attachments');
    function users_own_attachments( $wp_query_obj ) {
    
        global $current_user, $pagenow;
    
        if( !is_a( $current_user, 'WP_User') )
            return;
    
        if( 'upload.php' != $pagenow )
            return;
    
        if( !current_user_can('delete_pages') )
            $wp_query_obj->set('author', $current_user->id );
    
        return;
    }

    ________________

    I used the delete pages cap as a condition so Admins and Editors still see the full media listing.

    There is one small side effect, which i can’t see any hooks for, and that’s with the attachment counts shown above the media list(which will still show the total count of media items, not that of the given user – i’d consider this a minor issue though).

    wat heb je geprobeerd er mee?
    Dit moet je geloof ik na het gelezen te hebben in new-media.php aanpassen.

    I solved my problem with a pretty rough, but workable solution.
    
    1) I installed the WP Hide Dashboard plugin, so the User would only see a link to their profile edit form.
    
    2) In author.php template file, I inserted the code I used above.
    
    3) Then, for logged in users, I displayed a direct link to the Upload page "wp-admin/media-new.php"
    
    4) The next issue I noticed, was after they uploaded the photo, it would redirect them to upload.php... and they could see all the other pictures. I haven't found a hook into the media-new.php page, so I ended up hacking into the core "media-upload.php" and redirecting them to their profile page:

    Deze stappen al geprobeerd?

    Thread starter aw2

    (@aw2)

    … ben er nu nog mee aan de slag ;

    Succes! we horen het wel als er iets is.

7 reacties aan het bekijken - 1 tot 7 (van in totaal 7)
  • Het onderwerp ‘Beheer afbeeldingen in media library’ is gesloten voor nieuwe reacties.