BuddyDev

Search

[Resolved] Profile tabs depending to user role or member type

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

    Brajesh,

    Thank you so much!
    Does the code you gave me previously work with your Member type Pro plugin?

    Thanks,

    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #11853

    Hi Beuza,
    Can you please give this code a shot?

    
    
    /**
     * 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' );
    	}
    
    }
    
    add_action( 'bp_setup_nav', 'buddydev_remove_group_based_on_member_types', 1001 );
    
    /**
     * 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 works with our Member types pro and most probably will work with the other plugin too.

    Please make sure to use “agent” like shown below in the member type name.
    https://i.imgur.com/JdiZUTa.png

    Regards
    Brajesh

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

    Hello Brajesh,

    Thank you so much sir. It works perfectly! I can to go ahead thanks to you

    Thanks again,

    Beuza

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #11867
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #11868
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #11872
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #11873
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #11880
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #11882

    Marking the thread as resolved.

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

    Hi Brajesh,
    I finally have an issue with the code: member type Player can’t integrate agent’s group. I don’t want group menu tab display in their profile but i would like Players can integrate groups. The goal is to create a kind of agent portfolio for showing to scouts for example.
    Could you help me please?
    Thanks,

    Beuza

The topic ‘ [Resolved] Profile tabs depending to user role or member type’ is closed to new replies.

This topic is: resolved