【代碼】 給 bbPress 論壇增加個人資料菜單按鈕鏈接

·

也是因為有點煩,bbPress 功能太簡單了,想要調用資料頁面的幾個鏈接都沒辦法,只能是通過代碼實現,效果:

screenshot-2016-12-05-02-12-27

使用方法,添加到主題的 function.php 文件中

* Filter wp_nav_menu() to add profile link
*/
function prefix_bbp_profile_link_nav_menu($menu) {

    if ( !is_user_logged_in() )
        return $menu;
    else
        $current_user 				= 	wp_get_current_user();
        $user					=	$current_user->ID;
        $bbp_profile_url			=       bbp_get_user_profile_url( $user);
        $bbp_profile_menu_link	  	        = 	'<li>
			        				<a href=" '. esc_url( $bbp_profile_url ) .' "> '. __('👤 我的賬户', 'text-domain' ) .' </a>
							</li>';
        $menu         	= 	$menu . $bbp_profile_menu_link;

        return $menu;

}
add_filter( 'wp_nav_menu_items', 'prefix_bbp_profile_link_nav_menu' );