BuddyDev

Search

Mediapress Single Predefined User Gallery that can not be edited or deleted

  • Participant
    Level: Initiated
    Posts: 8
    Joseph Lawrence Walkollie on #45970

    The discussion here https://buddydev.com/support/forums/topic/mediapress-predefined-user-galleries/page/2/ is a good starting point, but I want to create single predefined gallery for every users and let users add, edit, and delete other galleries, but prevent the predefined gallery from being touched.

    Some help please, and thanks in advance.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #45972

    Hello Joseph,

    Thank you for posting. You can use the following code for predefined galleries form editing or deletion. Or you can use $user to find user predefined gallery and do not allow him/her from editing or deleting.

    
    
    // Prevent user form edit predefined gallery.
    add_filter( 'mpp_user_can_edit_gallery', function ( $can, $gallery, $user_id ) {
    	$predefined_gallery_id = 36;
    
    	if ( $predefined_gallery_id == $gallery->id ) {
    		$can = false;
    	}
    
    	return $can;
    }, 10, 3 );
    
    // Prevent user from deleting predefined gallery.
    add_filter( 'mpp_user_can_delete_gallery', function ( $can, $gallery, $user_id ) {
    	$predefined_gallery_id = 36;
    
    	if ( $predefined_gallery_id == $gallery->id ) {
    		$can = false;
    	}
    
    	return $can;
    }, 10, 3 );
    
    

    Please check and modify the solution as per your requirement.

    Regards
    Ravi

The topic ‘Mediapress Single Predefined User Gallery that can not be edited or deleted’ is closed to new replies.

This topic is: not resolved