A small list of improvements to the admin login page to make it look nicer/function better. Your clients will thank you so I’m sharing.
Change default WordPress admin login logo – Your own logo just looks more professional.
// Change default WordPress admin login logo
// NOTE: Change the width and height to match your image
if( !function_exists( 'ctm_custom_login_logo' ) ){
function ctm_custom_login_logo() {
echo '
<style type="text/css">
.login h1 a {
background-image: url(' . get_stylesheet_directory_uri() . '/assets/img/ctm-design-login.png) !important;
width:219px;
height:50px;
background-size: contain;
background-repeat: no-repeat;
padding-bottom: 15px;
}
</style>
';
}
add_action( 'login_head', 'ctm_custom_login_logo' );
}Add background image to WordPress admin login – Some folks like to have a background image as if used correctly can keep the look & feel of the main site intact.
// Add background image to WordPress admin login
function ctm_login_bg_image() {
echo '
<style type="text/css">
body{
background-image: url(' . get_stylesheet_directory_uri() . '/assets/img/ctm_admin_admin_login_background.jpg) !important;
}
</style>
';
}
add_action( 'login_enqueue_scripts', 'ctm_login_bg_image' );Change default URL (https://en-gb.projectdmc.org/) of admin login logo to home_url – What use is there in the login logo linking back to WordPress when it makes more sense to link to your own site.
// Change default URL (https://en-gb.projectdmc.org/) of admin login logo to home_url
function ctm_admin_login_logo_url() {
return home_url();
}
add_filter('login_headerurl', 'ctm_admin_login_logo_url');Change default alt title (Powered by WordPress) of admin login logo – No one wants their custom logo to say Powered by WordPress (do they?).
// Change default alt title (Powered by WordPress) of admin login logo
function ctm_admin_login_logo_url_title() {
return 'CTM Design - Web Design & Development';
}
add_filter( 'login_headertext', 'ctm_admin_login_logo_url_title' );Add custom message below admin login logo – Great for instructions to your clients or a reminder of support information. As an example, I just used a message asking the user to enter their username and password.
// Add custom message below admin login logo
function ctm_login_message( $message ) {
if ( empty($message) ){
echo '<span style="display: flex; justify-content: center">Please enter your username and password to continue.</span>';
} else {
return $message;
}
}
add_filter( 'login_message', 'ctm_login_message' );Replace “← Go to yoursite” link with something more useful – As we linked to the logon image to the home_url earlier this link becomes irrelevant so why not replace it with something of use.
// Replace "← Go to yoursite" link with something more useful
function set_login_backtohtml( $url ) {
$url="<span style="display: flex; justify-content: center">Designed with with <span style="color:red;">❤</span></span>";
return $url;
}
add_filter( 'login_site_html_link' , 'set_login_backtohtml' );Add custom message below admin login form – As an example I have set it up below to show a dynamic copyright.
// Add custom message below admin login form
function ctm_footer_login_message( $message ) {
if ( empty($message) ){
echo '<span style="display: flex; justify-content: center">©2023 - ' . date_i18n ('Y') . ' <img src="' . get_stylesheet_directory_uri() . '/assets/img/ctm-design-footer.png" align="absmiddle"> • All Rights Reserved.</span>';
} else {
return $message;
}
}
add_filter( 'login_footer', 'ctm_footer_login_message' );Redirect to homepage after logging in instead of admin area – Not everyone’s cup of tea but it may be of use to someone.
// Redirect to homepage after logging in instead of admin area
function ctm_custom_login_redirect() {
return home_url();
}
add_filter('login_redirect', 'ctm_custom_login_redirect');I have included everything as separate snippets for ease of selection and clarity on each function.
I also realise that snippets such as these are 10-a-penny for those that have looked but they are all useful and I feel would make great additions to ASE.
As I currently do not own the pro version and do not know all of its features, I apologise if any of the above have already been implemented.
Hopefully some are of use.
