Skip to:
Content
Pages
Categories
Search
Top
Bottom

Login, Register, Lost Password links

  • @mica123

    Participant

    I know that similar questions have been asked many times – unfortunately I have not found any satisfactory answers – I very much hope for your help as follows:
    I set up Forums on full page widths without sidebars.
    I would like to have the login, register and lost passwords links at the top of
    the forum page the same way as bbPress Support forum has – I am not referring to menu links.
    Can you please help?
    Many thanks.

Viewing 2 replies - 26 through 27 (of 27 total)
  • @robkk

    Moderator

    You can just use the code I posted here. It is more customizable then the other one in the codex article and the other topic you linked to. I might change it in the codex article later on to this one too.

    Login, Register, Lost Password links

    You can put a custom page like this '/page-slug/'. Here I made it so where when a user logs out they go to a page called “Logout” that has the permalink slug “logout”.

    add_filter( 'wp_nav_menu_items', 'rkk_add_auth_links', 10 , 2 );
    function rkk_add_auth_links( $items, $args ) {
        if (is_user_logged_in() && $args->theme_location == 'sub-header-menu') {
            $items .= '<li><a href="'. wp_logout_url('/logout/') .'">Log Out</a></li>';
        }
        elseif (!is_user_logged_in() && $args->theme_location == 'sub-header-menu') {
            $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
            $items .= '<li><a href="'. site_url('wp-login.php?action=register') .'">Register</a></li>';
            $items .= '<li><a href="'. site_url('wp-login.php?action=lostpassword') .'">Lost Password</a></li>';
        }
        return $items;
    }

    @mica123

    Participant

    Thanks @robkk – as always.

Viewing 2 replies - 26 through 27 (of 27 total)
  • You must be logged in to reply to this topic.
Skip to toolbar