Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_is_active() Returns False for Some Active Components


  • Pea
    Participant

    @misfist

    I’m developing a plugin that adds a custom group home page (groups/single/front.php. The page will display the latest activity for each component that as active for the group. In the template, I’m checking with bp_is_active( {component} ).

    The problem is that some of the components return false even though they are active, a tab is displayed for them.

    Only xprofile, activity, docs and members return true.

    global $bp; returns

    
    ["loaded_components"]=>
     ["loaded_components"]=>
      array(8) {
        ["forums"]=>
        string(6) "forums"
        ["members"]=>
        string(7) "members"
        ["profile"]=>
        string(8) "xprofile"
        ["activity"]=>
        string(8) "activity"
        ["groups"]=>
        string(6) "groups"
        ["settings"]=>
        string(8) "settings"
        ["events"]=>
        string(4) "bpeo"
        ["docs"]=>
        string(7) "bp_docs"
      }
    
    
    
    ["active_components"]=>
      array(6) {
        ["xprofile"]=>
        string(1) "1"
        ["settings"]=>
        string(1) "1"
        ["activity"]=>
        string(1) "1"
        ["groups"]=>
        string(1) "1"
        ["members"]=>
        string(1) "1"
        ["bp_docs"]=>
        string(1) "1"
      }
    
    

    In the template:

    
    <?php if ( bp_is_active( 'xprofile' ) ) : ?>
        <div class="buddypress-module xprofile intro">Intro</div>
    <?php endif; ?>
    <?php if ( bp_is_active( 'activity' ) ) : ?>
        <div class="buddypress-module activity">Activity</div>
    <?php endif; ?>
    <?php if ( bp_is_active( 'forums' ) ) : ?>
        <div class="buddypress-module forums replies">Replies</div>
        <div class="buddypress-module forums topics">Topics</div>
    <?php endif; ?>
    <?php if ( bp_is_active( 'blogs' ) ) : ?>
        <div class="buddypress-module blogs">Blogs</div>
    <?php endif; ?>
    <?php if ( bp_is_active( 'events' ) ) : ?>
        <div class="buddypress-module events">Events</div>
    <?php endif; ?>
    <?php if ( bp_is_active( 'bp_docs' ) ) : ?>
        <div class="buddypress-module docs">Docs</div>
    <?php endif; ?>
    <?php if ( bp_is_active( 'members' ) ) : ?>
        <div class="buddypress-module members">Members</div>
    <?php endif; ?>`
    
    

    Confirmed with twentysixteen
    WordPress 4.6.1
    BuddyPress 2.7.2

  • You must be logged in to reply to this topic.
Skip to toolbar