Hi Paul,
Thank you for asking.Yes, all of the above except the last one( I will get indo details of that is easily doable).
Here is the code you can put in your bp-custom.php//allow to create only one gallery function mpp_custom_check_gallery_create_permission( $can_do, $component, $user_id ) { if ( is_super_admin() ) { return true; } $total_gallery_count = mpp_get_total_gallery_for_user( $user_id ); if ( bp_is_my_profile() && $total_gallery_count < 1) { return true; } return false; } add_filter( 'mpp_user_can_create_gallery', 'mpp_custom_check_gallery_create_permission', 10, 3 ); //should we automatically create gallery? //allow deleting gallery? no //Restrict gallery deletion function mpp_custom_check_gallery_delete_permission( $can, $user_id ){ if ( is_super_admin() ) { return true; } return false;//do not allow i } add_filter( 'mpp_user_can_delete_gallery', 'mpp_custom_check_gallery_delete_permission', 10, 2 ); function mpp_custom_create_gallery() { if ( ! function_exists( 'mpp_is_user_gallery_component' ) ) { return; } if ( ! bp_is_my_profile() ) { return ; } $user_id = get_current_user_id(); $total_gallery_count = mpp_get_total_gallery_for_user( $user_id ); if ( $total_gallery_count ) { return ; } $gallery_id = mpp_create_gallery( array( 'creator_id' => $user_id, 'title' => sprintf( _x( "%s's Photos", 'wall gallery name', 'mediapress' ), bp_core_get_user_displayname( $user_id ) ), 'description' => '', 'status' => mpp_get_option( 'default_status' ), 'component' => 'members', 'component_id' => $user_id, 'type' => 'photo' ) ); if ( $gallery_id ) { mpp_update_wall_gallery_id( array( 'component' => 'members', 'component_id' => $user_id, 'media_type' => 'photo', 'gallery_id' => $gallery_id ) ); } } add_action( 'mpp_init', 'mpp_custom_create_gallery', 100 );
The above code restricts gallery creation to 1 gallery per user. It will automatically create a photo gallery for a user when the user visits his/her profile. It will not allow users to delete their gallery.
Now, coming to the last one, It is doable as we are storing the media count for each gallery in a meta. I haven’t added a filter to the query, so unable to put the code here. Please give me till tomorrow and I will update MediaPress, then we can restrict the empty gallery from showing.
Viewing 3 posts - 1 through 3 (of 3 total)
The topic ‘ [Resolved] User Galleries’ is closed to new replies.
This topic is: resolved