Site Logo on Login Page
/*******************************
=LOGIN PAGE
********************************/
// On login page, use Transom h1 link background (replacing WordPress logo):
function tr_login_logo() { ?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(<?php echo get_bloginfo( 'template_directory' ) ?>/images/img-logo-transparent-320.png);
padding-bottom: 20px;
}
</style>
<?php }
add_action( 'login_enqueue_scripts', 'tr_login_logo' );
// Transom URL for h1 link href:
function tr_login_logo_url() {
return 'http://transom.org/';
}
add_filter( 'login_headerurl', 'tr_login_logo_url' );
// Value for h1 link title:
function tr_login_logo_title() {
return 'Transom: Home';
}
add_filter( 'login_headertitle', 'tr_login_logo_title' );
Length of Login “Remember Me”
Change cookie length for “Remember Me” (default is 14 days):
// auth_cookie_expiration in pluggable.php
function keep_users_logged_in_for_1_month( $expirein ) {
return 2592000; // 30 days in seconds
add_filter( 'auth_cookie_expiration', 'keep_users_logged_in_for_1_month' );
}
Login Page-specific Code
if ( $GLOBALS['pagenow'] == 'wp-login.php' ) {
// Code for login page.
}
Login Page-specific Styles
*******************************
=LOGIN PAGE
******************************/
function cq_login_stylesheet() { ?>
<link rel="stylesheet" id="custom_wp_admin_css" href="<?php echo get_bloginfo( 'stylesheet_directory' ) . '/style-login.css'; ?>" type="text/css" media="all" />
<?php }
add_action('login_enqueue_scripts', 'cq_login_stylesheet');
/* Add site link URL to logo on login page. */
function cq_login_logo_url() {
return 'http://commaq.com/';
}
add_filter( 'login_headerurl', 'cq_login_logo_url' );
function cq_login_logo_url_title() {
return 'Comma-Q Architecture, Inc.';
}
add_filter( 'login_headertitle', 'cq_login_logo_url_title' );
Custom Login Page Template
<?php
/**
* Template Name: HW Enter/Login
*
* Login page: custom page template.
*
*/
get_header(); ?>
<div id="container">
<div id="content">
<h1><em><strong>Log In</strong></em></h1>
<div>
<?php
if (is_user_logged_in()) wp_loginout();
else wp_login_form('redirect=/wphw/wp-admin/'); ?><br />
<?php wp_register('', ''); ?>
</div>
<hr />
<h2 class="enter" id="posts">Posts: Latest (30)</h2>
<div class="site-list"">
<ul>
<?php
$args = array( 'numberposts' => 30, 'post_status' => 'publish' );
$recent_posts = wp_get_recent_posts( $args );
foreach($recent_posts as $post){
echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' . $post["post_title"].'</a></li>';
} ?>
</ul>
</div>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<!-- =template: hw_enter -->
<?php get_footer(); ?>
</body>
</html>
Notes for Codex Login Doc
Notes accompanying writing the WordPress Codex page: http://codex.wordpress.org/Customizing_the_Login_Form
Display in HTML where hooks fire:
// Test where actions and filters display on login page:
add_action( 'login_init', 'a_login_init' );
function a_login_init() { echo "\n<!-- =HOOK: a_login_init -->\n"; }
add_action( 'login_enqueue_scripts', 'a_login_enqueue_scripts' );
function a_login_enqueue_scripts() { echo "\n<!-- =HOOK: login_enqueue_scripts -->\n"; }
add_action( 'login_head', 'a_login_head' );
function a_login_head() { echo "\n<!-- =HOOK: login_head -->\n"; }
add_filter( 'login_headerurl', 'f_login_headerurl' );
function f_login_headerurl() { return "FILTER-login_headerurl"; }
add_filter( 'login_headertitle', 'f_login_headertitle' );
function f_login_headertitle() { return "FILTER: login_headertitle"; }
add_filter( 'login_message', 'f_login_message' );
function f_login_message() { return "<strong><em>FILTER: login_message</em></strong>"; }
add_filter( 'login_errors', 'f_login_errors' );
function f_login_errors() { return "=HOOK: f_login_errors"; }
add_action( 'login_form', 'a_login_form' );
function a_login_form() { echo "<strong><em>ACTION: login_form</em></strong>"; }
add_action( 'login_footer', 'a_login_footer' );
function a_login_footer() { echo "<strong><em> ACTION: login_footer</em></strong>"; }