最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - Buddypress: adding a new tab direct user to their author page

programmeradmin1浏览0评论

Hi, This is regarding buddypress adding new tab to the member profile main nav and when is click direct user to the author posts www.mysite/Author/username/

After researching and looking I have find this code that it kinder works, it creates a new custom tab and direct users to the new post but the URL is not what i'm looking for it creates member/username/mypost what I need is something like this www.mysite/Author/username/ I just don't understand how i can achieve this with this code below....

function ibenic_buddypress_tab() { global $bp; bp_core_new_nav_item( array( 'name' => __( 'My Posts', 'ibenic' ), 'slug' => 'my-posts', 'position' => 100, 'screen_function' => 'ibenic_budypress_my_posts', 'show_for_displayed_user' => true, 'item_css_id' => 'ibenic_budypress_my_posts' ) ); }

Hi, This is regarding buddypress adding new tab to the member profile main nav and when is click direct user to the author posts www.mysite/Author/username/

After researching and looking I have find this code that it kinder works, it creates a new custom tab and direct users to the new post but the URL is not what i'm looking for it creates member/username/mypost what I need is something like this www.mysite/Author/username/ I just don't understand how i can achieve this with this code below....

function ibenic_buddypress_tab() { global $bp; bp_core_new_nav_item( array( 'name' => __( 'My Posts', 'ibenic' ), 'slug' => 'my-posts', 'position' => 100, 'screen_function' => 'ibenic_budypress_my_posts', 'show_for_displayed_user' => true, 'item_css_id' => 'ibenic_budypress_my_posts' ) ); }

https://www.youtube/watch?v=-K1vGcH3gSY

Share Improve this question asked Jan 31, 2020 at 16:07 HamadiHamadi 134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

In your screen function ibenic_budypress_my_posts create a redirect. Something like:

function ibenic_buddypress_tab() { 
    bp_core_new_nav_item( array( 'name' => __( 'My Posts', 'ibenic' ), 'slug' => 'my-posts', 'position' => 100, 'screen_function' => 'ibenic_budypress_my_posts', 'show_for_displayed_user' => true, 'item_css_id' => 'ibenic_budypress_my_posts' ) ); 
}

function ibenic_budypress_my_posts() {
    $url = '/author/' . bp_get_displayed_user_username();
    bp_core_redirect( site_url( $url ) );
}
发布评论

评论列表(0)

  1. 暂无评论