In this article, we will learn how to customize the default WordPress login page.
- Change the login logout redirection page.
- Change the Logo URL.
- Change Default Logo.
- Change Default Design.
Set Custom Login Page.
Here we will set the URL after login where we want to redirect.
I find some plugin on WordPress reposetry but it's not a good idea.
Customizing the WordPress Login ---
This function redirect on contact us page after Logout.
I find some plugin on WordPress reposetry but it's not a good idea.
"Redirect after login without any plugin"
Customizing the WordPress Login ---
This function redirect on custom login page default login page replaced.
add_action('login_redirect','login_redirect_fun');
function login_redirect_fun(){
wp_redirect( home_url('/custom_login_page/') ); //Add your page url
exit;
}
This function redirect on contact us page after Logout.
add_action('wp_logout','logout_redirect');
function logout_redirect(){
wp_redirect( home_url('/contact-us/') ); //You can change url
exit;
}
This function this function rplace your default wordpress logo and URL.
function my_login_logo_url() {
return home_url(); //here you can add any url
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
Here we can add our logo and bacgkgroud image and font color etc.
Note: copy all code and past in functions.php file.
function my_login_logo() { ?>
<style type="text/css">
//Your logo image here
div#login h1 a {
background-image: url(https://cdn.pixabay.com/photo/2016/11/18/11/17/youtube-1834016_960_720.png);
}
//page background image
.login{
background-image: url("https://cdn.pixabay.com/photo/2013/05/09/09/06/waves-circles-109964_960_720.jpg");
color: #ffff;
background-repeat: no-repeat;
background-size: cover;
}
form#loginform {
background-color: #00000030;
}
.login #backtoblog a, .login #nav a {
text-decoration: none;
color: #ffffff !important;
}
.login #login_error {
border-left-color: #d63638;
color: #f50000;
}
</style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );
logo -
2 Comments
After login redirect on specific page use this code -
ReplyDeleteadd_action('get_header', function() {
if (is_page( 'login' ) && is_user_logged_in()&& !is_admin()) {
$author_link = get_author_posts_url( get_current_user_id() );
wp_redirect(''.$author_link);
}
});
One click solution just copy and past it -
ReplyDeleteadd_action( 'login_enqueue_scripts', 'wp_login_logo' );
if(!function_exists('wp_login_logo')){
function wp_login_logo() {
$logo_url = esc_url( wp_get_attachment_url( get_theme_mod( 'custom_logo' ) ) ); ?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo $logo_url; ?> );
width:300px;
height:80px;
background-size: 280px 56px;
background-repeat: no-repeat;
padding: 10px;
background-position: center;
}
</style><?php
}
}
function my_login_logo_url() {
return home_url(); //here you can add any url
}
add_filter( 'login_headerurl', 'my_login_logo_url' );