Site logo

[Resolved] Exclude BuddyPress members page from Page Hero block element

Home Forums Support [Resolved] Exclude BuddyPress members page from Page Hero block element

Home Forums Support Exclude BuddyPress members page from Page Hero block element

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2310340
    Cheryl

    Hi,
    I have a GP block element that is a page hero that gets applied to most pages on my site.

    However, I do NOT want it on BuddyPress pages. I tried excluding the page itself — excluding it from the login page worked, but the main BP page /user/ has many child pages and if I exclude Page:User the page hero remains on the user page and all of its children.

    Is there a way I can exclude a block element from all BuddyPress pages?
    Thanks

    #2310506
    Ying
    Staff
    Customer Support

    Hi Cheryl,

    Can you try this snippet? Replace 951 with the element’s ID, and 77 with the parent page ID.

    add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
        global $post;
        if ( 951 === $element_id && ( is_page() && $post == post_parent > 77 || is_page(77)) ) {
            $display = false;
        }
        return $display;
    }, 10, 2 );

    Let me know if this works.

    #2310539
    Cheryl

    No, unfortunately, that didn’t do it. I saw a snippet like that in another post in the forum here and had tried it.

    I’ve tried excluding the member page, the groups page, and the register page this way and it doesn’t work. Neither does excluding those pages on the Page Hero element itself.

    I suppose I could INCLUDE the page hero only on select pages but that would be very cumbersome and take a lot of time. But as a last resort, I could do it…though it would be nice if there were a way to exclude it from any BuddyPress page.

    Somehow, excluding the Buddypress login page in the element DOES work and removes the page hero element there.
    Thanks.

    #2310783
    David
    Staff
    Customer Support

    Hi there,

    try this snippet:

    add_filter( 'generate_element_display', function( $display, $element_id ) {
        if ( 10 === $element_id ) {
            if ( function_exists( 'is_buddypress' ) && is_buddypress() ) {
                return false;
            }
        }
    
        return $display;
    }, 10, 2 );

    Change the 10 to the ID of the Element.
    This should disable that element wherever Buddypress templates are loaded.

    #2310935
    Cheryl

    Hi,
    Thanks for the snippet. Unfortunately, that also did not work. I also found and tried the snippet to exclude the element from pages that have the featured image disabled. That also did not work in this case.

    But I went ahead and added some CSS to move the box around the membership page fields up so they overlap the blank page hero. This looks good enough to me.

    Thanks again for the help.

    #2310946
    David
    Staff
    Customer Support

    Doh — i made a mistake in the Code here:

    https://generatepress.com/forums/topic/exclude-buddypress-members-page-from-page-hero-block-element/#post-2310783

    just updated that if you want to give it another go.

    #2311101
    Cheryl

    That worked beautifully! Thanks!
    Cheryl

    #2311104
    David
    Staff
    Customer Support

    Glad to hear that!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.