Created
June 14, 2013 11:04
-
-
Save sambody/5781055 to your computer and use it in GitHub Desktop.
WP: login page customization
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
/* ================ LOGIN PAGE CUSTOMIZATION | |
*/ | |
// 1. Add stylesheet | |
function sam_custom_login_styles(){ | |
?><link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/forms.css" type="text/css" /> | |
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/login.css" type="text/css" /> | |
<?php | |
} | |
add_action('login_head', 'sam_custom_login_styles'); | |
// 2. Change logo link url and title (change logo image in login.css) | |
function sam_login_header_url(){ | |
return "/"; | |
} | |
add_action('login_headerurl', 'sam_login_header_url'); | |
function sam_login_header_link_title(){ | |
return "Back to home page"; | |
} | |
add_action('login_headertitle', 'sam_login_header_link_title'); | |
// 3. Add a login message | |
function sam_login_message($msg){ | |
return $msg . "<p class=\"login-welcome\">Welcome. Please login first.</p>"; | |
} | |
add_action('login_message', 'sam_login_message'); | |
// 4. Redirect non admin users to home page after login (they can still access admin later) | |
function sam_login_redirect( $redirect_to, $request, $user ) { | |
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : site_url(); | |
} | |
add_filter( 'login_redirect', 'sam_login_redirect', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment