Today, we are going to change the default wordpress login logo, logo anchor link, and redirect link after the user logins to the website.
CODE LINK:
PLEASE CHANGE THE URL WITH YOUR WEBSITE URL
function custom_login_redirect( $url, $request, $user ) {
if ( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if ( $user->has_cap( 'administrator' ) ) {
$url = admin_url();
} else {
$url = home_url( '/REDIRECT-URL-AFTERLOGIN/' );
}
}
return $url;
}
add_filter( 'login_redirect', 'custom_login_redirect', 10, 3 );
function custom_login_logo() {
?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(https://yourwebsite.com/path/image.png);
height:65px;
width:320px;
background-size: contain;
background-repeat: no-repeat;
padding-bottom: 30px;
}
</style>
<?php
}
add_action( 'login_enqueue_scripts', 'custom_login_logo' );
function change_login_logo_url() {
return 'https://YOURWEBSITE.com/';
}
add_filter( 'login_headerurl', 'change_login_logo_url' );
function change_login_logo_url_title() {
return 'Your Website Title';
}
add_filter( 'login_headertext', 'change_login_logo_url_title' );
/**
* Disable admin bar
*/
function disable_admin_bar_for_non_admins(){
if (!current_user_can('administrator')) {
add_filter('show_admin_bar', '__return_false');
}
}
add_action('after_setup_theme', 'disable_admin_bar_for_non_admins');