Skip to:

Why is my custom component inactive

  • Andrew Tibbetts


    it is getting skipped via:

    if ( !bp_is_active( $component_name ) )

    here is the function that creates the component:

    function pc_notifier_setup_globals() {
    global $bp, $current_blog;
    $bp->pc_notifier=new stdClass();
    $bp->pc_notifier->id = 'pc_notifier';//I asume others are not going to use this id
    $bp->pc_notifier->slug = BP_COMMENT_NOTIFIER_SLUG;
    $bp->pc_notifier->notification_callback = 'pc_notifier_format_notifications';//show the notification
    /* Register this in the active components array */
    $bp->active_components[$bp->pc_notifier->slug] = $bp->pc_notifier->id;

    do_action( 'pc_notifier_setup_globals' );
    add_action( 'bp_setup_globals', 'pc_notifier_setup_globals' );

    WP: 3.4.2
    BP: 1.6.1

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

  • modemlooper


    You should be extending BP_Component class to create new components.

    Not sure we have a tutorial or clear example of how to extend BP_Component yet.

    Andrew Tibbetts


    Are there any existing situations in the code I can look at?



    I wrote a page about it in the codex but that page has been completely erased. Here’s the page that had info on extending it and when I went to respond to this topic and post a link I saw the page has been erased.

    The revisions are even wiped out.

    I wonder if someone deleted it. I don’t know how we’d tell, unless it’s in google’s history.

    @johnjamesjacoby ping. Maybe we should disallow page deletion on the codex for non-admins?



    If it was deleted it would not have revisions. Page is there.



    I’d check out the BP Skeleton Component sample plugin.  That should show you how to extend the BP_Component class for your new plugin.



    Andrew Tibbetts


    Thanks everyone, I’m on my way. But, now I’m getting a 500 error on plugin activation. I replaced out the deprecated component creation function above with the following:

    define( 'BP_PCN_IS_INSTALLED', 1 );
    define( 'BP_PCN_PLUGIN_DIR', dirname( __FILE__ ) );

    /* Only load the component if BuddyPress is loaded and initialized. */
    function bp_pcn_init() {
    // Because the loader file uses BP_Component, it requires BP 1.5 or greater.
    if ( version_compare( BP_VERSION, '1.5', 'active_components[$this->id] = '1';


    function setup_globals() {
    global $bp;

    // Defining the slug in this way makes it possible for site admins to override it
    if ( !defined( 'BP_PCN_SLUG' ) )
    define( 'BP_PCN_SLUG', $this->id );

    // Set up the $globals array to be passed along to parent::setup_globals()
    $globals = array(
    'slug' => BP_PCN_SLUG,
    'root_slug' => isset( $bp->pages->{$this->id}->slug ) ? $bp->pages->{$this->id}->slug : BP_PCN_SLUG,
    'has_directory' => false, // Set to false if not required
    'notification_callback' => 'bp_pcn_format_notifications'

    // Let BP_Component::setup_globals() do its work.
    parent::setup_globals( $globals );



    /* load component into $bp global */
    function bp_pcn_load_core_component() {
    global $bp;

    $bp->pcn = new BP_PCN_Component;
    add_action( 'bp_loaded', 'bp_pcn_load_core_component' );

    Anyone know what I’m missing?

    Andrew Tibbetts


    Decided to give up modifying my existing plugin and just modify the Skeleton plugin that r-a-y recommended—much better idea. I now have the notification count displaying! No notification text but I’m pretty sure I’ll get there. Thanks all!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Why is my custom component inactive’ is closed to new replies.
Skip to toolbar