Skip to:
Content
Pages
Categories
Search
Top
Bottom

“$bp->current_component” returns empty string


  • anbusurendhar
    Participant

    @anbusurendhar

    Hi!
    I’ve just referred ‘John James Jacoby’ to create a custom page dynamically without going into the admin panel.

    I can get the current component name in default buddypress pages using the below code:

    global $bp; var_dump($bp->current_action);

    But the problem I face here is that when I try create a new page as mentioned in the ‘John James Jacoby’, I get 404 error. I can’t figure out what is going on. Any help would be appreciated.

    Thanks in Advance..

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

  • danbp
    Participant

    @danbp

    I can’t figure out what is going on.

    That snippet is 6 years old. BuddyPress is slightly different today.

    Some explanation here:

    bp_is_current_component

    bp_current_action

    May be you can also read here:

    Template Overload from a Plugin


    anbusurendhar
    Participant

    @anbusurendhar

    @danbp : Thank You very much for your reply.

    Even I’ve tried bp_current_component() and bp_is_current_component() functions with no success.

    Actually this function works fine when used in default buddypress pages like domain/activity/. This returns me “activity”, which is exactly correct. But when I tried this in my custom page (domain/custompage), I’m getting an empty string.


    danbp
    Participant

    @danbp

    Can you give details about what you’re trying to build ?
    Add custom page dynamically is not enought.


    anbusurendhar
    Participant

    @anbusurendhar

    In buddypress, activity, members, group have a definite pages like ‘domain/activity’, ‘domain/members’, ‘domain/group’, respectively. Likewise I’m trying to create my own custom page like ‘domain/mycustom’.

    For this purpose I referred John James Jacoby’s Post in here. The snippet used in that link didn’t work for me. I don’t know where I’m missing.

    From that snippet, I found that $bp->current_component returns me an empty string.


    anbusurendhar
    Participant

    @anbusurendhar

    Sorry the link is Link. My mistake


    anbusurendhar
    Participant

    @anbusurendhar

    https://buddypress.org/support/topic/make-your-own-custom-buddypress-page/.

    The snippet I found in the above link is as below:

    
    define('BP_EXAMPLE_SLUG', 'fun');
    
    function bp_show_example_page() {
    
    global $bp, $current_blog;
    
    if ( $bp->current_component == BP_EXAMPLE_SLUG && $bp->current_action == '' ) {
    
    // The first variable here must match the name of your template file below
    
    bp_core_load_template( 'fun', true );
    
    }
    
    }
    
    add_action( 'wp', 'bp_show_example_page', 2 );
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘“$bp->current_component” returns empty string’ is closed to new replies.
Skip to toolbar