Site logo

Archived topic

Block elements just don't like BP pages

26 replies · Started by Carsten on October 16, 2020

Viewing posts 16–27 of 27

Sorry, no difference

Any chance you can provide temporary admin login details so I can take a closer look?

Sure, thanks for looking into this.

Perhaps that conditional from BP isn't working.

Does this add anything to the page?:

add_action( 'generate_before_header', function() {
    if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {
        echo 'activity page';
    }
} );

No, sorry

Strange, all the searching I've done points to that being the correct condition.

Can you disable your caching plugin?

Hi there, I appreciate your persistence to solve this issue, but no difference with deactivated cache, and with this code


add_action( 'generate_before_header', function() {
    if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {
        echo 'activity page';
    }
} );

add_action( 'bp_before_member_header_meta', 'yzc_add_xprofile_field_data_in_profile_header' );

I went into the BuddyPress core code and found when they add the activity class to the body.

Instead of this:

if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {

Try this:

if ( function_exists( 'bp_is_activity_component' ) && bp_is_activity_component() ) {

Hi, this code only display the text 'activity page' in the header?

How does this code connect the Block Element without id?

add_action( 'generate_before_header', function() {
   if ( function_exists( 'bp_is_activity_component' ) && bp_is_activity_component() ) {
        echo 'activity page';
    }
} );

That function is just to test.

Now that we know it works, we can do this:

add_filter( 'generate_block_element_display', function( $display, $element_id ) {
    if ( 123 === $element_id ) {
        if ( function_exists( 'bp_is_activity_component' ) && bp_is_activity_component() ) {
            return true;
        }
    }

    return $display;
}, 10, 2 );

Hi there, great, it's working perfectly.

Thanks a lot for bringing up a solution!

How do I get the element contained like the rest of the page?
Block set to to Full width, alternativ is wide width, page content set to contained?

https://imgur.com/pA8HmtT

Regards
Carsten

If you want it to be contained then you should de-select the full-width option (you don't have to choose full width or wide width).

Glad we got it working :)

This archived topic is closed to new replies.