Question

replacing wordpress login logo

Hello guy’s i know this is not related to server setup, but i know ill find many expert here who can help me out.

i need to replace the wordpress logo from the wp-login.php

so i added following in my themes function.php

/*** Custom LOGO ***/
add_action( 'login_enqueue_scripts', 'my_login_logo' );

function custom_login_logo() {
    echo '<style type="text/css">'.
             'h1 a { background-image:url('.get_bloginfo( 'template_directory' ).'/assets/my-logo.png) !important; }'.
         '</style>';
}
add_action( 'login_head', 'custom_login_logo' );

it replaces the logo, but whenever i login i get this error massage in my error.log

2017/06/08 17:28:13 [error] 3588#3588: *222 FastCGI sent in stderr: "PHP message: PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, function 'my_login_logo' not found or invalid function name in /var/www/mysite/html/wp-includes/class-wp-hook.php on line 298" while reading response header from upstream, client: 103.205.121.545, server: mysite.com, request: "GET /wp-login.php?redirect_to=https%3A%2F%2Fmysite.com%2Fwp-admin%2F&reauth=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "mysite.com"

anyone can guide me here?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@newbie

The issue is with the first add_action function call.

If a function named my_login_logo does not exist in your code, adding an action that would call it will result in the warning or an error.

Looking at the WordPress docs:

https://codex.wordpress.org/Customizing_the_Login_Form

You should use:

function my_login_logo() {
    echo '<style type="text/css">'.
             'h1 a { background-image:url('.get_bloginfo( 'template_directory' ).'/assets/my-logo.png) !important; }'.
         '</style>';
}

add_action( 'login_enqueue_scripts', 'my_login_logo' )

There are a few other examples as well, which includes changing links, further styling, etc.

@newbie

It shouldn’t, no, though ultimately the only way to tell if something is impacting performance is to use a monitor or conduct performance metric testing. If you’re not currently seeing higher levels of traffic, it will be a little harder to do that since with low levels of traffic (or no traffic), you can’t really tell unless it is something major.