BuddyDev

Search

[Resolved] BP template tag breaks my site

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #35576

    Hi there, for some reason the tag bp_is_profile_edit()is breaking my site, while the rest of the tags like bp_is_user_profile()listed here are fine. https://codex.buddypress.org/developer/template-tag-reference/#is_-functions
    According to the documentation it should still work. Conditional template tags allow you to show specific content on specific pages. The following tags are available in BuddyPress (1.2+):

    Any idea why this specific template tag does not work?

    Regards
    Carsten

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #35579

    Hello Carsten,

    Thank you for posting. Both function does the same thing. ‘bp_is_profile_edit’ is the older version of ‘bp_is_user_profile_edit’ which was deprecated since BuddyPress 1.5. You can use ‘bp_is_user_profile_edit’ in place of ‘bp_is_profile_edit’.

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #35580

    Hi Ravi, thanks for the clarification, the bp_is_user_profile_edit is working, while the bp_is_profile_edit is not. strange that bp_is_user_profile_edit apparently is not listed in the Template Tag Reference.

    Regards
    Carsten

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #35583

    Hello Carsten,

    Thank you for the acknowledgement. Yes, It seems somehow they forgot to update this. Marking this as resolved.

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #35584

    Hi again Ravi, can you inform me if bp_is_settings_component()is deprecated as well?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #35585

    Hello Carsten,

    No, It is not deprecated you can use function with no problem.

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #35592

    Hi Ravi, thanks again, you have been most helpful. For some reason it has no effect in this function, where this element should be hided on the /members/profilename/settings/ but I must look for a solution elsewhere.

    add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
        if ( 45256 === $element_id && bp_is_current_component( "bp-messages" ) || bp_is_settings_component() ) {
            $display = false;
        }
    
        return $display;
    }, 10, 2 );

    Regards
    Carsten

    • This reply was modified 3 years, 3 months ago by calu.
    • This reply was modified 3 years, 3 months ago by calu.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #35595

    Hello Carsten,

    Try the following code.

    
    
    add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
    
    	// If element id is 45256 and current component is message. Not display.
    	if ( 45256 == $element_id && bp_is_current_component( 'messages' ) ) {
    		$display = false;
    	} elseif ( bp_is_settings_component() ) {
    		// If is settings component set display to false.
    		$display = false;
    	}
    
    	return $display;
    }, 10, 2 );
    

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #35597

    Hi Ravi, thanks for the code. It output the same result.

    What I need is to hide the two tags individually, so the statement should be an OR.

    Is elseif = || ?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #35603

    Hello Carsten,

    Try the follwing code.

    
    add_filter( 'generate_hook_element_display', function ( $display, $element_id ) {
    
    	if ( 45256 != $element_id ) {
    		return $display;
    	}
    
    	// If message component or setting set display to false.
    	if ( bp_is_messages_component() || bp_is_settings_component() ) {
    		$display = false;
    	}
    
    	return $display;
    }, 10, 2 );
    

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: resolved