Skip to:
Content
Pages
Categories
Search
Top
Bottom

What’s the screen function for the buddypress profile front page?


  • enderpal444
    Participant

    @enderpal444

    I’m trying to set up paging for the budddypress profile page. On the font page I display a loop of posts and the only way I found to paginate was to add “page” as a subnav like this.

    ` if ( (int) bp_posts_cur_page() > 0) {
    bp_core_new_subnav_item( array(
    ‘name’ => ‘Page ‘. bp_posts_cur_page(),
    ‘slug’ => ‘page’,
    ‘parent_slug’ => $bp->slug,
    ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/’,
    ‘screen_function’ => ‘bp_core_catch_profile_uri’,
    ‘position’ => 20,
    ) );
    bp_core_new_subnav_item( array(
    ‘name’ => ‘Page ‘.bp_posts_cur_page(),
    ‘slug’ => bp_posts_cur_page(),
    ‘parent_slug’ => $bp->slug . ‘/page’,
    ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/page/’,
    ‘screen_function’ => ‘bp_core_catch_profile_uri’,
    ‘position’ => 20,
    ) );
    }`

    Now I left out a few important parts that makes that work but it’s just to understand what I’m doing. I just need the correct screen function for the top level of the profile so that mysite.com/exampleuser/page is pointing at the same screen as mysite.com/exampleuser/. Any idea?

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

  • modemlooper
    Moderator

    @modemlooper

    xprofile_screen_display_profile


    enderpal444
    Participant

    @enderpal444

    @modemlooper Do you see any flaw in my code givin that I’m using xprofile_screen_display_profile? This method worked perfectly when creating loops under say mysite.com/exampleuser/articles/ but its isn’t paging for the top level. It just takes me to a blank members screen. hmmm


    modemlooper
    Moderator

    @modemlooper

    oops wrong function. This will add a sub nav under profile called Page. I don;t think you can change the slug for this item for different pages. What you would want is /page/name-of-page/

    In BuddyPress the part after /page/ would be considered an action variable. So you could do a looopy of some sorts to get the action and match it up to a page.

    Example code to read the variable and then you could display an appropriate page. if you visit /page/2/ it will echo the string. action variables are anything after an action. page is the action so anything in between slashes = variable and they are stored in an array.

    if you had this in the url:
    page/2/3/4/

    the variables can be accessed like this:
    $bp->action_variables[0] = 2
    $bp->action_variables[1] = 3
    $bp->action_variables[3] = 4

    `function bp_page_nav(){
    global $bp;

    $user_domain = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();

    $profile_link = trailingslashit( $user_domain . $bp->profile->slug );

    bp_core_new_subnav_item( array(
    ‘name’ => ‘Page’,
    ‘slug’ => ‘page’,
    ‘parent_url’ => $profile_link,
    ‘parent_slug’ => $bp->profile->slug,
    ‘screen_function’ => ‘page_screen’,
    ‘position’ => 20

    ) );
    }
    add_action(‘bp_setup_nav’, ‘bp_page_nav’, 10 );

    function page_screen(){
    global $bp;

    add_action( ‘bp_template_content’, ‘bp_page_screen_content’ );

    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }

    function bp_page_screen_content(){
    global $bp;

    $variable = $bp->action_variables[0];

    if( $variable == ‘2’ ){
    echo ‘page 2’;
    }

    }
    `


    enderpal444
    Participant

    @enderpal444

    @modemlooper Really appreciate the explanation! I got it working with infinite scroll on a user ‘s front page to show their posts which is a nice extension. Thanks alot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘What’s the screen function for the buddypress profile front page?’ is closed to new replies.
Skip to toolbar