BuddyDev

Search

[Resolved] Restrict upload to own gallery

  • Participant
    Level: Initiated
    Posts: 1
    Sergio Passaro on #48990

    Is it possible to restrict image uploads to only the user’s own galleries in a group? I see that all members of a group can post to any gallery. I am using Mediapress with Buddypress integrated into Tutor LMS.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2944
    Ravi on #48992

    Hello Sergio,

    Thank you for the posting. Please use the following code:

    
    add_filter( 'mpp_user_can_upload', function ( $can_do, $component, $component_id, $gallery ) {
    
    	// Only allow uploads to the user's own galleries.
    	if ( 'groups' === $component && get_current_user_id() != $gallery->user_id ) {
    		$can_do = false;
    	}
    
    	return $can_do;
    }, 10, 4 );
    

    Please let me know if it helps or not.

    You can use this code in your active theme “functions.php” file or “bp-custom.php” file.

    If you do not know what is bp-custom.php file. Look at the following link:
    https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 1
    Sergio Passaro on #48993

    Excelent! It works nicely! Thank you.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2944
    Ravi on #48994

    Hello Sergio,

    Thank you for the acknowledgement. I am glad to help you.

    Regards
    Ravi

The topic ‘ [Resolved] Restrict upload to own gallery’ is closed to new replies.

This topic is: resolved