Why do You Need a Customized Login Page for WordPress ?
Here are the two ways you can go through:
You can contact experts from popular WordPress Development Company from USA for any questions.
Let’s continue reading below solutions!
1. Use Existing WordPress Layout.
add_action('login_head', 'my_custom_login');
function my_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/your_login_styles.css" />';}
add_filter( 'login_headerurl', 'my_login_logo_url' );
function my_login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
function my_login_logo_url_title() {
return 'Your Site Name and Info';}
The most convenient way to change the error message is by the below code in your functions.php :
add_filter('login_errors', 'login_error_override');
function login_error_override()
{
return 'Incorrect login details.';
}
Related : WordPress vs Adobe Business Catalyst : Which CMS is Best for Developing?
2. Create a New Layout.
A global information technology solutions agency providing fresh, creative digital services to businesses who want to grow online. Focusing on results, we use our technical skill and industry insight to help you meet your digital goals. Whether that’s lowering your bounce rate with interactive web design or bringing brand new traffic and income streams to your website. <a href=”www.elsner.com/contact-us”>Talk to us</a> about your project to get started…
</p>
</div>
<div class="login-form">
<?php
$args = array(
'redirect' => home_url(),
'id_username' => 'user',
'id_password' => 'pass',
);
?>
<?php wp_login_form( $args ); ?>
</div>
add_action('init','redirect_login_page');
function redirect_login_page() {
$login_page = home_url( '/login/' );
$page_viewed = basename($_SERVER['REQUEST_URI']);
if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET')
{
wp_redirect($login_page);
exit;
}
}
– The page of login may work as per the expectation after we are logged in. In case an error occurs, like when submitting invalid id and password combination, or submitting empty spaces, we will be redirected to wp-login.php. In order to solve this issue, you may add the following function in your functions.php:
add_action( 'wp_login_failed', 'login_failed' );
function login_failed() {
$login_page = home_url( '/login/' );
wp_redirect( $login_page . '?login=failed' );
exit;
}
add_filter( 'authenticate', 'verify_username_password', 1, 3);
function verify_username_password( $user, $username, $password ) {
$login_page = home_url( '/login/' );
if( $username == "" || $password == "" ) {
wp_redirect( $login_page . "?login=empty" );
exit;
}
}
– The Final Problem is that we will also get redirected to wp-login.php when we are logged out of the site. Therefore, we need to specify the redirecting URL upon the logout as well.
add_action('wp_logout','logout_page');
function logout_page() {
$login_page = home_url( '/login/' );
wp_redirect( $login_page . "?login=false" );
exit;
}
So yeah! That is it.
With the few simple tweaks, you can quite comfortably personalize your login page to match the appearance and feel of your site.
A lot of theme designers refrain from styling the login page as they deem it unnecessary, especially when it is out of the WordPress theme setup.
However, when you are creating a client site, neglecting style – and significantly, the brand – the login page can prove to be a lost opportunity that could break the user’s experience when there is a custom theme in place.
The other opportunity to brand your site, which also leaves a long lasting impression in your user’s mind.
Let us write your business’s growth story by offering innovative, scalable and result-driven IT solutions. Do you have an idea that has a potential to bring a change in the world? Don’t hesitate, share with our experts and we will help you to achieve it.