How to change wordpress login page

/**
 * Change the Login Logo Image and Background
 */
function custom_login_logo() {
    ?>
    <style type="text/css">
        /* Custom login logo */
        #login h1 a, .login h1 a {
            background-image: url('change-this-to-full-url-of-your-logo.png');
            height: 65px;
            width: 320px;
            background-size: contain;
            background-repeat: no-repeat;
            padding-bottom: 0px;
        }

        /* Add a background image to the login page */
        body.login {
            background-image: url('change-this-to-full-url-of-the-background-image.png');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }

    </style>
    <?php
}
add_action( 'login_enqueue_scripts', 'custom_login_logo' );
/* END CODE  */

/**
 * Change the Login Logo Anchor Link
 */
function change_login_logo_url() {
    return 'https://changethistoyourwebsiteurl.com/';
}
add_filter( 'login_headerurl', 'change_login_logo_url' );
/* END CODE  */

/**
 * Change the Login Logo Title Tag
 */
function change_login_logo_url_title() {
    return 'Change This Your Website Name';
}
add_filter( 'login_headertext', 'change_login_logo_url_title' );
/* END CODE  */

/**
 * Disable admin bar
 */
function disable_admin_bar_for_non_admins(){
    if (!current_user_can('administrator')) {
        add_filter('show_admin_bar', '__return_false');
    }
}
add_action('after_setup_theme', 'disable_admin_bar_for_non_admins');
/* END CODE  */

/**
 * Change Redirect URL Logging In If User Role Is NOT Admin
 */
function custom_login_redirect( $url, $request, $user ) {
    if ( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
        if ( $user->has_cap( 'administrator' ) ) {
            $url = admin_url();
        } else {
            $url = home_url( '/change-this-to-your-redirect-page/' );
        }
    }
    return $url;
}

add_filter( 'login_redirect', 'custom_login_redirect', 10, 3 );
/* END CODE  */

Gel Manalastas

I love to tinker and take things apart, and then put them together in new and better ways. I am at my best when looking for ways to improve things. Just tell me what is the issue and 'what' you want to accomplish. I'll find a way on 'how' to accomplish it. My strengths are completing things, finding ways to improve systems, making things simpler.

Leave a Comment

Your email address will not be published. Required fields are marked *

Get help with your website needs

Leave your contact details below and I will get back to you as soon as I can.