Monday, September 05, 2011

Hide login link in Wordpress

Most Wordpress based websites are not community based and either do not need user feedback or simply do not require user registration. Unfortunately Wordpress still exposes the 'login' link at the banner of the page often confusing the users. This article shows a little hack to hide the login link.

Browse the FTP server which hosts the wordpress installation and open the following file:

<root directory>/wp-includes/general-template.php

Now locate the following function:

function wp_loginout($redirect = '', $echo = true) {
    if ( ! is_user_logged_in() )
        $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
    else
        $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
 
    if ( $echo )
        echo apply_filters('loginout', $link);
    else
        return apply_filters('loginout', $link);
}

and replace it with the following code:

function wp_loginout($redirect = '', $echo = true) {
    if ( ! is_user_logged_in() )
        $link = ''; //'<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
    else
        $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
 
    if ( $echo )
        echo apply_filters('loginout', $link);
    else
        return apply_filters('loginout', $link);
}

This will hide your login link!
Post a Comment