Support » Fixing WordPress » Linking cookie notice on the wp-login page

  • Resolved Ate Up With Motor


    Current versions of WordPress automatically place a Privacy Policy link on the wp-login page, which is good. However, I can’t see any way (short of hacking core files) to add a link to a cookie notice, and I don’t know of any cookie banner plugin that places a banner on the login page.

    Does anyone know of a way to do this?

    • This topic was modified 2 months, 4 weeks ago by t-p. Reason: Moved to Fixing WordPress from Developing with WordPress
Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator bcworkz


    No need to alter core files. There are a number of hooks you can use where added callback code can output whatever HTML content you want. More on hooks in WP:

    That’s good to know, but I have absolutely no idea how I would use those to achieve the goal I’m describing. Are there any tutorials about placing custom HTML on the wp-login page?

    Moderator bcworkz


    It’s not that complicated, though I get that if you don’t know what to do the information presented can seem insurmountable. Start with this code added to your theme’s functions.php (preferably a child theme’s file):

    add_action('login_header', 'my_cookie_notice');
    add_action('login_footer', 'my_cookie_notice');
    function my_cookie_notice() {
    <style>.my-cookie-notice { text-align: center; background-color: aliceblue; padding: 10px;}</style>
    <div class="my-cookie-notice">If you don't want us to store cookies in your browser, please don't log in</div>

    Depending on where you want the notice to appear, remove one or the other add_action() lines. Edit the style and HTML portion as you wish.

    Ah! This is extremely helpful, thank you. I will have to tinker with the format, but I think that should do the trick.

    A tangentially related question: By default, the input fields of the login form use a light yellow background color, but I can’t figure out where it’s pulling that color from (I’ve been poking at it with Inspect Element in Firefox without success, and I don’t know enough about the hierarchy of core CSS to find it in the code).

    What is the hex code for that color? The reason I ask is that it seems like a good background color for the banner I’m creating — it’s dark enough to draw the eye, but light enough to provide good text contrast.

    Thanks again!

    Moderator bcworkz


    The yellow is actually from your browser’s auto-fill feature. The default field background color from WP is light gray (#fbfbfb). It looks to me like the yellow is #fff8c6, according to my image editor’s color picker tool.

    Ah! I am embarrassed to admit it didn’t occur to me at all that the background color would be browser-specific rather than something set by WordPress CSS, which would explain why I was having so much trouble getting Inspect Element to tell me what it was. Thank you again!

    Moderator bcworkz


    Don’t be embarrassed! It’s sneaky the way it’s implemented. I’m not sure precisely how it is done. Until recently, it was something I was unaware of as well and couldn’t figure out. It was only due to reading WP support chat that I learned where the yellow was coming from. I don’t think it’s commonly known. A better rationale than we’re some of the last to know 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.