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 badges1 Answer
Reset to default 0In 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 ) );
}