Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: [Resolved] Member Types Pro – Emergency #11669

    Continuing the discussion on email and will update it accordingly.

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: [Resolved] Buddypress Profile order Tab #11668

    Hi Tiziano,
    you have the

    <?php
    
    

    tag missing in the bp-custom.php

    It should be the first thing.

  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    Hi Tom,
    Yes, you can. bp_template_redirect is hooked to WordPress template_redirect action, so it will work from the child theme’s functions.php too.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    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.

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on 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

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: [Resolved] Email Restrict not working #11659
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    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

  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    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?

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: [Resolved] Email Restrict not working #11652
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on 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