Replies
- Brajesh Singh on November 11, 2017 at 2:54 am in reply to: [Resolved] Member type to restrict and grant access to groups #11662
Hi Tom,
You may put thhis code in your bp-custom.php/** * Restrict user from accesisng groups of which he/she is not a member and it's not allowed as part of their member type. */ function buddydev_restrict_group_access_based_on_member_type() { if ( ! is_user_logged_in() || ! bp_is_group() || is_super_admin() ) { return;// it's not group or the user is not logged in, do not restrict. } $group_id = groups_get_current_group()->id; $user_id = bp_loggedin_user_id(); // user's own group, do not restrict. if ( groups_is_user_member( $user_id, $group_id ) ) { return; } // Member types pro is not active, return. if ( ! function_exists( 'bpmtp_member_types_pro' ) ) { return; } // Get all member types for user, user may have multiple member type. $member_types = bp_get_member_type( $user_id, false ); if ( empty( $member_types ) ) { return ; // what should we do? the user does not have any member type. } // let us build a list of group ids allowed with these member types. $group_ids = array(); $active_types = bpmtp_get_active_member_type_entries(); foreach ( $member_types as $member_type ) { // not valid. if ( empty( $member_type ) || empty( $active_types[ $member_type ] ) ) { continue; } $mt_object = $active_types[ $member_type ]; $associate_groups_ids = get_post_meta( $mt_object->post_id, '_bp_member_type_groups', true ); // merge. if ( ! empty( $associate_groups_ids ) ) { $group_ids = array_merge( $group_ids, $associate_groups_ids ); } } if ( ! empty( $group_ids ) && in_array( $group_id, $group_ids ) ) { return;// this group is associated with the member types the user has, so do not restrict. } // Restrict if we are here, $referrer = wp_get_referer(); $referrer = $referrer ? $referrer : site_url( '/' ); // add notice. bp_core_add_message( 'Access restricted', 'error' ); bp_core_redirect( $referrer ); } add_action( 'bp_template_redirect', 'buddydev_restrict_group_access_based_on_member_type' );It will redirect logged in user to previous page if they are not member of the group or is not allowed by member type.
Hope that helps.
- Brajesh Singh on November 10, 2017 at 10:30 pm in reply to: [Resolved] Buddypress Profile order Tab #11660
Hi Tiziano,
Thank you for the patience.Please remove your code snippet that you are already using.
Then, please put this in your bp-custom.php
/** * Reorder BuddyPress profile tabs/navigation. */ function buddydev_reorder_buddypress_profile_tabs() { $bp = buddypress(); $nav = $bp->members->nav; // it's a map of nav items for user profile to their position. $nav_items = array( 'settings' => 10, 'activity' => 20, 'friends' => 30, 'groups' => 40, 'blogs' => 50, 'messages' => 60, 'profile' => 70, ); foreach ( $nav_items as $nav_item => $position ) { $nav->edit_nav( array( 'position' => $position ), $nav_item ); } } add_action( 'bp_setup_nav', 'buddydev_reorder_buddypress_profile_tabs', 999 );That will do it for you.
Hope that helps.
Regards
Brajesh - Brajesh Singh on November 10, 2017 at 6:54 pm in reply to: [Resolved] Email Restrict not working #11659This reply has been marked as private.
- Brajesh Singh on November 10, 2017 at 6:53 pm in reply to: [Resolved] How to change size of avatar or make lightbox work on avatar #11658
Hi Carsten,
BuddyPress uses 50px for thumb and 150px for the normal by default. You can change that easily by definign a few constants.
Please see the example here.https://buddydev.com/buddypress/changing-default-avatar-size-croppedused-by-buddypress/
Hope that helps.
Regards
Brajesh - Brajesh Singh on November 10, 2017 at 6:50 pm in reply to: [Resolved] Option for setting the gender of profiles showing in BP plugins #11657
Hi Carsten,
Thank you for posting.At the moment there is no standard way to know a user’s gender and that’s why there are no specified ways.
For a developer, It is easy to accomplish.
If I had to do something for this, I will create member types for gender and use that to filter the things.
How are you using gender on your site?
- Brajesh Singh on November 10, 2017 at 3:19 am in reply to: [Resolved] Email Restrict not working #11652This reply has been marked as private.
- Brajesh Singh on November 10, 2017 at 3:07 am in reply to: [Resolved] Email Restrict not working #11650
Hi Krista,
Thank you.
1. I have marked your reply as private. Please never share any login detaiils in public. Also, I will suggest immediately changing the password. In future, Please use the “Set as private reply” checkbox below the form to send any credentials. Please do share the password after the changing.2. I have checked on the site and the registration is disabled. Should I enable and then check it?
3. The plugin restricts registration. It means any user with an email from some other site(not specified in the list) will not be able to register. It does not restrict login for your existing user.
If you allow me to enable the registration, I can quickly check why It is not restricting.
Thank you
Brajesh - Brajesh Singh on November 10, 2017 at 2:50 am in reply to: [Resolved] Member type to restrict and grant access to groups #11647
Hi Tom,
Thank you.I am sorry for the confusion about group association, The goal is to automatically assign groups to user when their member type changes.
I do see other user cases and most probably we will extend it more in future. At the moment, we do not restrict based on member types but if you or someone can suggest a list of extensive restrictions, I will be happy to have them in the plugin. We do want to look into this territory.
Regards
Brajesh - Brajesh Singh on November 10, 2017 at 2:35 am in reply to: [Resolved] Member type to restrict and grant access to groups #11645
Hi Tom,
Thank you for purchasing the plugin.Let me clarify a few things first:-
1. you can set the member type manually using any of the following option
a) from the User->All Users screen you can select the change member type option and change it in bulk/single.
b) If you have xprofile field(member types, It is not necessary though), You can do it from user profile edit on the front end or the User Profile edit extended section in the backend.2. You can assign member types based on roles, The plugin allows you to map that too. Please see
https://buddydev.com/docs/guides/plugins/buddypress-plugins/buddypress-member-types-pro/assigning-buddypress-member-types-based-wordpress-roles/Now, here is the solution I am proposing.
1. Map role to Member types(role change should update user member type)
2. Use WooCommerce membership to make role change, It will trigger the change of member type
3. Do not let member type change WooCommerce Membership(Just don’t associate on the member type screen)Now, we have a system where your user registers via WooCommerce or purchases membership via WooCommerce
and his member type is based on which membership he/she purchase.The first part of your issue is resolved by that approach.
Now, restricting the content of a group based on member types.
With the above setup, we know which member type has which groups associated(We are changing the meaning of group association here, will use them to sandbox the user).
We can write some code to stop users from accessing groups not in their member type’s allowed list. I will post code example today/tomorrow for this.
Hope it helps.
Regards
Brajesh - Brajesh Singh on November 10, 2017 at 2:12 am in reply to: [Resolved] >> Configure BuddyPress Multi Network #11643This reply has been marked as private.