Quantcast
Channel: bbPress.org » All Posts
Viewing all articles
Browse latest Browse all 3638

Reply To: Edit the bbPress login widget

$
0
0

Try the following

//adds login/logout to menu
//filter to add login/logout to menu
add_filter( 'wp_nav_menu_items', 'my_nav_menu_login_link' );
function my_nav_menu_login_link($menu) {
    //uncomment the next line if you only want login on bbpress pages
    //if(is_bbpress()) {
    if (is_user_logged_in()) {
        //set the $url on the next line to the page you want users to go back to when they logout
        $url = 'http://www.mysite.com/forums' ;
        $url2=wp_logout_url($url) ;
        $loginlink = '<li><a title="Logout" href="'.$url2.'">Logout</a></li>';
        }
    else {
        $current_user = wp_get_current_user();
        $user=$current_user->user_login ;
        //set $page on the next line = the permalink for your login page
        $page='login' ;
        $loginlink = '<li><a href="/'.$page.'/">Login</a></li>';
                }
    //uncomment out the next lines if you only want login on bbpress pages
    //      }
    //  else {
    //  $loginlink="" ;
    //      }
        $menu = $menu . $loginlink;
        return $menu;
}

Viewing all articles
Browse latest Browse all 3638

Trending Articles