Replies
- Brajesh Singh on February 1, 2016 at 2:27 pm in reply to: [Resolved] Mediapress – Predefined User Galleries #2460
Thank you. Here we go with the code. Please put these code blocks in your bp-custom.php
1. Let us stop user from creating gallery
// Stop gallery creation, only superadmin can function mpp_custom_check_gallery_create_permission( $can_do, $component, $user_id ) { if ( is_super_admin() ) { $can_do = true; //ok super admin can create it } else { $can_do = false;//no one else can } return $can_do; } add_filter( 'mpp_user_can_create_gallery', 'mpp_custom_check_gallery_create_permission', 10, 3 );
That will stop users from creating gallery. Site admins can still create it.
2. Let us stop users from editing gallery
// Restrict gallery editing function mpp_custom_check_gallery_edit_permission( $can, $gallery, $user_id ){ // only superadmin can if ( is_super_admin() ) { $can = true; } else { $can = false; } return $can;//do not allow it at all } add_filter( 'mpp_user_can_edit_gallery', 'mpp_custom_check_gallery_edit_permission', 10, 3 );
That will stop users from editing gallery but allow siteadmins to do so.
Step 3: Let us stop users from deleting gallery
// Restrict gallery deletion function mpp_custom_check_gallery_delete_permission( $can, $user_id ){ // only superadmin can if ( is_super_admin() ) { $can = true; } else { $can = false; } return $can;//do not allow it at all } add_filter( 'mpp_user_can_delete_gallery', 'mpp_custom_check_gallery_delete_permission', 10, 2 );
and the final step, let us create the predefined galleries automatically for the user.
In this example, I have created only one gallery, you can modify the repeatable block(make sure to change the user meta key for each) and create as many predefined galleries as you want. When a user visits his/her own profile, the galleries will be created.function mpp_custom_auto_create_gallery() { if ( ! bp_is_my_profile() ) { return ; } //make sure that user gallery functions are available if ( ! function_exists( 'mpp_create_gallery' ) ) { return; } $user_id = get_current_user_id(); //does this user has predefined gallery? //we use this check to avoid same type of gallery again and again for the user if ( ! get_user_meta( $user_id, '_mpp_predefined_gallery_photo_1', true ) ) { //No, then we need to create it. //repeat it as you want $gallery_id = mpp_create_gallery( array( 'creator_id' => $user_id, 'title' => __( 'Predefined Photo Gallery' ), 'description' => '', //add description if any 'status' => mpp_get_default_status(),//can use any of the status e.g. 'public' , 'private', 'loggedin', 'friends' etc 'component' => 'members',//for user 'component_id' => $user_id,//no need to change 'type' => 'photo', //can change to "audio", "video", "doc" ) ); //let us keep the id in usermeta to avoid creating it again, right? if ( ! is_wp_error( $gallery_id ) ) { update_user_meta( $user_id, '_mpp_predefined_gallery_photo_1', $gallery_id ); //you can change the key to anything } }//end of repeatable block //go ahead, do it for other types too } add_action( 'bp_template_redirect', 'mpp_custom_auto_create_gallery');
Please do let me know how it goes for you.
Thank you
Brajesh- This reply was modified 4 years, 11 months ago by
Brajesh Singh. Reason: updated to fix the gallery creation. Was missing the template redirect hook attachment
- This reply was modified 4 years, 11 months ago by
- Brajesh Singh on February 1, 2016 at 1:41 pm in reply to: [Resolved] Mediapress – Predefined User Galleries #2458
Thank you. That makes it clear. I will have some code in 30 mins to an hour.
Thank you
Brajesh - Brajesh Singh on February 1, 2016 at 1:31 pm in reply to: [Resolved] Mediapress – Predefined User Galleries #2456
Hi,
Thank you for asking. I have a few questions before I can put the sample code for you.1. Do you want users to be able to upload from activity or not?
2. Do you want to allow users to delete the predefined galleries or not?
3. Can you please explain what do you mean by
“Additionally, I need to split the images and videos into separate entities. Currently it’s all in one.”
MediaPress does not allow uploading video/photo to one gallery. It is the default behaviour to have separate galleries for each of the type.
Thank you
Brajesh Thank you.
I will put a copy for you to test a little bit late today. giving a final push for activity, if not, will disable that and push the copy.Hi ,
I am sorry to keep you waiting. How much important is gallery activity migration for your site?I have been working on it but the activity migration is not going in the right direction. I was even working on it in the day and was going to ask you the question.
Also, do you use add from web or not or your site?
If you can answer these two question, I may have something to showcase even today.
Hi Jan,
Can you please look into my suggestions and let me know if that worked for you or not?Thank you
BrajeshHi Jay,
Thank you for clarifying.There are a few solutions for this available.
You may want to look at these and see if it solves the issue
1. https://wordpress.org/plugins/media-vault/
2. https://wordpress.org/plugins/delightful-downloads/I will prefer the first one as that does not have any extra UI requirement and uses WordPress uploader.
Please give it a try and let me know how it goes.
Thank you
Brajesh- Brajesh Singh on January 29, 2016 at 12:54 am in reply to: [Resolved] Hide Members based on Member Type? #2442
Hi Kenny,
Marking this topic as resolved a per email. The code works.In future, if you are unable to post reply, please try refreshing the browser and you will be shown as properly logged in. It happens sometimes due to caching.
Thank you
Brajesh - Brajesh Singh on January 29, 2016 at 12:49 am in reply to: No 'All Galleries' page and no 'Wall Photos' gallery #2441
Hi Mike,
I just implemented the shortcode today. It still needs final touch but is available on github repo now.https://github.com/buddydev/mediapress
Here is a screenshot to show how it looks
http://i.imgur.com/uAiM7BB.pngI am not sure how to handle the case when a user does not have any gallery available, should we create one automatically when a user uploads for the first time?
The shortcode can currently handle single gallery uploads(if you provide gallery_id or can list galleries based on other parameters and user access(status,type,component,component_id) and let users select the gallery to upload to.
I still need some idea for what the real life needs are and will appreciate your suggestions here.
Thank you
Brajesh - Brajesh Singh on January 28, 2016 at 12:32 am in reply to: [Resolved] Hide Members based on Member Type? #2439
Hi Kenny,
Welcome to BuddyDev forums.Please use the following code
add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users_by_member_type' ); function buddydev_exclude_users_by_member_type( $args ) { //do not exclude in admin if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { return $args; } $excluded_member_type = isset( $args['member_type__not_in'] )? $args['member_type__not_in'] : array(); if ( ! is_array( $excluded_member_type ) ) { $excluded_member_type = explode(',', $excluded_member_type ); } //member types to exclude, change it $types_to_exclude = array( 'student', 'teacher' );//add your own list $excluded_member_type = array_merge( $excluded_member_type, $types_to_exclude ); $args['member_type__not_in'] = $excluded_member_type; return $args; }
You can specify one or more member type by their unique name in $types_to_exclude array.
Please let me know if that works or not?
Thank you
Brajesh