Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Hide join button conditionally


  • psmorrow
    Participant

    @psmorrow

    Hi,

    Is is possible to hide the join button with php? I don’t want to hide it using CSS because I don’t want to hide it all the time. Namely, i want it visible for a certain user type, which is specified during user registration.

    Any assistance is greatly appreciated!

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

  • danbp
    Participant

    @danbp

    See http://hookr.io/plugins/buddypress/#index=g&search=bp_get_member_types

    1 – get the member types
    2 – if $mt == the_allowed_type
    3 – show the button


    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 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 🙂


    danbp
    Participant

    @danbp

    You don’t absolutely need an else statement.


    shanebp
    Moderator

    @shanebp

    All filters need to return something.

    Try:

    function bp_remove_group_join_button( $button, $group ) {
    	
    	$member_type = xprofile_get_field_data( 'Member Type', bp_get_member_user_id());	
    	
    	if ( $member_type == 'Option 1' ) 	
    		return '';
    	
            return $button;	
    }	
    add_filter( 'bp_get_group_join_button', 'bp_remove_group_join_button', 10, 2);

    psmorrow
    Participant

    @psmorrow

    Thanks for you help! Got it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Hide join button conditionally’ is closed to new replies.
Skip to toolbar