Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 18 replies - 1 through 18 (of 18 total)

  • psmorrow
    Participant

    @psmorrow

    I got this working instead:

    function action_xprofile_data_after_save( $array ) { 
    
    		bp_set_member_type( get_current_user_id(), 'current-student', false );	
    }
             
    
    add_action( 'xprofile_data_after_save', 'action_xprofile_data_after_save', 10, 1 );
    

    psmorrow
    Participant

    @psmorrow

    This solution is even better because it displays the leave group button, which could be helpful, if you want to restrict users to 1 group only, but be able to leave 1 group and join another….

    function action_groups_member_before_save( $array ) { 
    	
    	$user_id = bp_loggedin_user_id();
    	$result = groups_total_groups_for_user($user_id);
    
    	if ( $result > 0 ) {
    
    		wp_die('You can only join 1 group	');
    	}
    
    	return $button;
    
    	}
    
    add_action( 'groups_member_before_save', 'action_groups_member_before_save', 10, 1 ); 
    

    psmorrow
    Participant

    @psmorrow

    function bp_remove_group_join_button2( $button, $group ) {
    
    	$user_id = bp_loggedin_user_id();
    	$result = groups_total_groups_for_user($user_id);
    
    	if ( $result > 0 ) {
    
    		return '';
    	}
    
    	return $button;
    	
    }	
    add_filter( 'bp_get_group_join_button', 'bp_remove_group_join_button2', 10, 2);
    

    psmorrow
    Participant

    @psmorrow

    Hello Kind souls.
    A please for assistance on the post above.
    Sincerely,
    Pete


    psmorrow
    Participant

    @psmorrow

    Got this working today:

    function bp_change_default_subnav() {
    	global $bp;	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Events',
    		'slug'                  => 'events',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,		
    		'position'              => 800,
    		'default_subnav_slug'   => 'attending'
    	) );
    }
    add_action( 'bp_setup_nav', 'bp_change_default_subnav', 5 );
    

    psmorrow
    Participant

    @psmorrow

    Just to clarify, the Events tab already exists. I am trying to change the default sub-tab of ‘events’ to the subtab named ‘attending’


    psmorrow
    Participant

    @psmorrow

    Tried this, without success:

    function bp_change_default_subnav() {
    	global $bp;	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Events',
    		'slug'                  => 'events',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,		
    		'position'              => 700,
    		'default_subnav_slug'   => 'attending'
    	) );
    }
    add_action( 'bp_setup_nav', 'bp_change_default_subnav', 100 );
    

    Any suggestions?


    psmorrow
    Participant

    @psmorrow

    Thanks for the reply. I’ll try to explain what I’m trying to do: I’m using the Events Manager plug in, and for the Events tab, I want to default to the tab named “Events I’m Attending” (slug is ‘attending’). I’m hiding the previous tabs, which is why i want to default to the named attending

    If you aren’t familiar with the Events Manager plug in, I’m happy to stick to the hypothetical example of my snippet above, in which I try (but not successfully) to set the default sub-tab of the settings tab to ‘notifications’.

    Hope this helps explain things!


    psmorrow
    Participant

    @psmorrow

    been thinking more about it, and I really hope to update the user role with a custom function. I can’t figure out why the code above won’t do this? Any suggestions you have are greatly appreciated!


    psmorrow
    Participant

    @psmorrow

    Thanks for the explanation and insight danbp! I am not married to updating the user role with a function. The only reason I wanted to do it is because I’m using the events manager plugin and I don’t want basic members to have permissions that are determined using the role. And I’m open to other options….

    If i update the role with a function, I can avoid hiding a bunch of things using functions…which is easy enough….but my thinking was that updating the role was more efficient.

    I do want to do this automatically, because I want to grant users privileges during registration.

    Which do think is a better option: hiding a bunch of screen elements with a function based on the member_type attribute I created; or, updating the role at registration and have these element hidden automatically using the Events Manager plugin?

    Many thanks again!


    psmorrow
    Participant

    @psmorrow

    Thanks for you help! Got it!


    psmorrow
    Participant

    @psmorrow

    I think i’m on the right track, but not sure what to return on else condition:

    
    function bp_remove_group_join_button() {
    	
    	$member_type = xprofile_get_field_data( 'Member Type', bp_get_member_user_id());	
    	
    	if ( $member_type == 'Option 1' ) {
    	
    		return '';
    	}
    	else {
    		return ????;
    	}		
    }	
    add_filter( 'bp_get_group_join_button', 'bp_remove_group_join_button');
    

    But, i’m open to other approaches that work 🙂


    psmorrow
    Participant

    @psmorrow

    thanks! got it!


    psmorrow
    Participant

    @psmorrow

    Thank you very much for the guidance!

    can you help with the code to show/hide the button?


    psmorrow
    Participant

    @psmorrow

    I found this:

    post

    which adds xprofile fields to member directory, but I can’t seem to get this working for the group members directory.


    psmorrow
    Participant

    @psmorrow

    Thanks, got it!


    psmorrow
    Participant

    @psmorrow

    Can you also show how to add the calendar tab to a group page after the home tab?

    A thousand thanks again for your help!


    psmorrow
    Participant

    @psmorrow

    works awesome, thanks!

Viewing 18 replies - 1 through 18 (of 18 total)
Skip to toolbar