New
PeoplePress is here. Community building for WordPress, reimagined. Fast, modern, and built for the communities you've always wanted to run.
See it live

BuddyDev

Search

Issue with provided code (profile tab depending to member type)

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #12024

    Hello Brajesh,

    I cross my fingers so that you can take a look on my issue soon.
    I know you must have a lot of work.

    Thanks again,

    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #12031

    Hi Beuza,
    Sorry about that. Will certainly have some update today.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #12065

    Hello Brajesh,

    Do you know nearly when that could be possible?

    Thank you
    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #12136

    Hi Beuza,
    I am almost done with all my backlogs. I will be able to assist you tomorrow.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #12153

    Hi Brajesh,

    Understood!

    Thanks,

    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #12179

    Hi Beuza,
    here is the code

    
    /**
     * Remove groups from user profile based on member type.
     */
    function buddydev_remove_group_based_on_member_types() {
    	if ( ! bp_is_user() ) {
    		return;
    	}
    
    	$user_id = bp_displayed_user_id();
    
    	if ( ! bp_has_member_type( $user_id, 'agent' ) ) {
    		bp_core_remove_nav_item( 'groups' );
    
    		$access = bp_core_can_edit_settings();
    		$friends_link = bp_displayed_user_domain()? bp_displayed_user_domain() : bp_loggedin_user_domain();
    		$friends_link = trailingslashit( $friends_link . bp_get_friends_slug() );
    		bp_core_new_subnav_item(array(
    			'name'            => __( 'Invitations', 'buddypress' ),
    			'slug'            => 'invites',
    			'parent_url'      => $friends_link,
    			'parent_slug'     => bp_get_friends_slug(),
    			'screen_function' => 'buddydev_groups_screen_group_invites',
    			'user_has_access' => $access,
    			'position'        => 30
    		));
    		// move the invitations to the friends screen.
    	}
    }
    
    add_action( 'bp_setup_nav', 'buddydev_remove_group_based_on_member_types', 1001 );
    
    /**
     * Helps us detect screen.
     */
    function buddydev_groups_screen_group_invites() {
        add_action( 'groups_screen_group_invites', 'buddydev_load_invite_template' );
    	groups_screen_group_invites();
    }
    
    /**
     * Load our template.
     */
    function buddydev_load_invite_template() {
        add_action( 'bp_template_content', function () {
            bp_get_template_part('members/single/groups/invites');
        });
    
    	bp_core_load_template('members/single/plugins' );
    }
    
    /**
     * Change the invite link url for the non 'agent' users.
     *
     * @param string $link original link.
     *
     * @return string
     */
    function buddydev_update_group_invite_link( $link ) {
        // for agent, do not break it.
        if ( bp_has_member_type( bp_loggedin_user_id(), 'agent' ) ) {
           return $link;
        }
    
    	global $groups_template;
    
    	if ( empty( $group ) ) {
    		$group =& $groups_template->group;
    	}
    
    	return wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/invites/accept/' . $group->id ), 'groups_reject_invite' ) ;
    }
    
    add_filter( 'bp_get_group_accept_invite_link', 'buddydev_replace_group_to_friends_in_group_invite' );
    
    /**
     * Change the reject link url for the non 'agent' users.
     *
     * @param string $link original link.
     *
     * @return string
     */
    function buddydev_update_group_reject_link( $link ) {
        // for agent, do not break it.
        if ( bp_has_member_type( bp_loggedin_user_id(), 'agent' ) ) {
           return $link;
        }
    
    	global $groups_template;
    
    	if ( empty( $group ) ) {
    		$group =& $groups_template->group;
    	}
    
    	return wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/invites/reject/' . $group->id ), 'groups_reject_invite' ) ;
    }
    
    add_filter( 'bp_get_group_reject_invite_link', 'buddydev_replace_group_to_friends_in_group_invite' );
    
    /**
     * Remove groups from adminbar based on member type.
     *
     * @param array $nav nav items.
     *
     * @return array
     */
    function buddydev_filter_show_hide_groups_in_adminbar( $nav ) {
    	if ( ! is_user_logged_in() ) {
    		return $nav;
    	}
    
    	if ( ! bp_has_member_type( bp_loggedin_user_id(), 'agent' ) ) {
    		$nav = array();
    	}
    
    	return $nav;
    }
    
    add_filter( 'bp_groups_admin_nav', 'buddydev_filter_show_hide_groups_in_adminbar' );
    
    

    It should work. Can you please give it a try? I haven’t tested it but it should work.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #12239

    Hello Brajesh,

    Thank you for your help. Unfortunatly the code doesn’t work. I still have the “Oops! That page can’t be found” when a player tempt to accepting group membership invitation sent by an agent. Do you want access to my website?

    Thanks,

    Beuza

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #12240

    Brajesh,

    When i try to accept the invitation by the subtab Invitation in Friends tab, when i clic on accept, the page refreshed but there is no acceptance took in account.
    Do you imagine what’s wrong?

    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #12245

    Hi Beuza,
    It’s strange but quiet possible as we are moving the handlers and all.

    I was trying to avoid settings up it on local as I will need to recreate the whole thing, so Yes, It will be nice if you can give me an account who has the requests pending.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #12246
    This reply has been marked as private.

You must be logged in to reply to this topic.

This topic is: not resolved