The following is a code snippet originally posted by Daniel McClure on GitHub as a Gist.
functions.php
“`
‘;
}
add_action(‘login_head’, ‘my_custom_login’);
function my_login_logo_url() {
return get_bloginfo( ‘url’ );
}
add_filter( ‘login_headerurl’, ‘my_login_logo_url’ );
function my_login_logo_url_title() {
return ‘Your Site Name and Info’;
}
add_filter( ‘login_headertitle’, ‘my_login_logo_url_title’ );
function login_error_override() {
return ‘Incorrect login details.’;
}
add_filter(‘login_errors’, ‘login_error_override’);
function admin_login_redirect( $redirect_to, $request, $user ) {
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( “administrator”, $user->roles ) ) {
return $redirect_to;
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter(“login_redirect”, “admin_login_redirect”, 10, 3);
“`
style.css
“`
html {
height: 100%;
background: #ffffff url(‘ENTER_URL’) no-repeat center top fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body {
background: none;
min-width: 0;
padding-top: 8%;
color: #FFF;
}
#login {
background-color: #ffffff;
border: 0 solid #ffffff;
-webkit-border-radius: 11px;
border-radius: 11px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
background-color: rgba(255,255,255,0.85);
padding: 15px 20px;
}
.login #login_error,
.login .message {
background-color: #444;
}
.login h1 a {
background-image: url(‘ENTER_URL’);
background-size:auto;
width: 300px;
height: 132px;
}
“`
Original Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Cheatsheet for customising the WordPress Login page | |
function my_custom_login() { | |
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/login/ENTER_URL.css" />'; | |
} | |
add_action('login_head', 'my_custom_login'); | |
function my_login_logo_url() { | |
return get_bloginfo( 'url' ); | |
} | |
add_filter( 'login_headerurl', 'my_login_logo_url' ); | |
function my_login_logo_url_title() { | |
return 'Your Site Name and Info'; | |
} | |
add_filter( 'login_headertitle', 'my_login_logo_url_title' ); | |
function login_error_override() { | |
return 'Incorrect login details.'; | |
} | |
add_filter('login_errors', 'login_error_override'); | |
function admin_login_redirect( $redirect_to, $request, $user ) { | |
global $user; | |
if( isset( $user->roles ) && is_array( $user->roles ) ) { | |
if( in_array( "administrator", $user->roles ) ) { | |
return $redirect_to; | |
} else { | |
return home_url(); | |
} | |
} else { | |
return $redirect_to; | |
} | |
} | |
add_filter("login_redirect", "admin_login_redirect", 10, 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
height: 100%; | |
background: #ffffff url('ENTER_URL') no-repeat center top fixed; | |
-webkit-background-size: cover; | |
-moz-background-size: cover; | |
-o-background-size: cover; | |
background-size: cover; | |
} | |
body { | |
background: none; | |
min-width: 0; | |
padding-top: 8%; | |
color: #FFF; | |
} | |
#login { | |
background-color: #ffffff; | |
border: 0 solid #ffffff; | |
-webkit-border-radius: 11px; | |
border-radius: 11px; | |
-moz-background-clip: padding; | |
-webkit-background-clip: padding-box; | |
background-clip: padding-box; | |
background-color: rgba(255,255,255,0.85); | |
padding: 15px 20px; | |
} | |
.login #login_error, | |
.login .message { | |
background-color: #444; | |
} | |
.login h1 a { | |
background-image: url('ENTER_URL'); | |
background-size:auto; | |
width: 300px; | |
height: 132px; | |
} |
Leave a Reply