• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Change a CSS class if user logged in vs logged out

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Change a CSS class if user logged in vs logged out

This topic is: not resolved

Tagged: classes, condition, css, logged in, logged out

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by Ben @ Inbound Creative.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 22, 2014 at 2:29 am #125270
    MM
    Member

    Hi, I'm trying to change CSS around a button depending on whether a user is logged in or logged out.

    No link yet as on localhost.

    For example,

    Not logged in.... the Log In button is:

    `
    background-color: #000;
    padding: 10px;
    color: #fff;
    border-radius: 15px;

    And when a user IS logged in, I don't want 'Sign Out' (which the button becomes) to be a call to action highlighted button.

    Rather, it should be

    background-color: #fff;
    color: #000;

    Does anyone know how to achieve this? Sounds like some form of conditional CSS class... thanks for the help!

    September 22, 2014 at 3:05 am #125277
    Ben @ Inbound Creative
    Member

    I've never tried this, so it might not work.

    However, when you're logged in, WordPress itself adds a page class of logged-in.

    Try this:

    .logged-in .classname {
         background-color: #fff;
         color: #000;
    }

    Change .classname to whatever your class name is. You might also need to add a 'a' selector after the class name, but you shouldn't need it.

    The alternative is to use the same class name structure, but then use 'display: none;' instead of the background color and color.

    Let me know if that works.


    Award winning web design in Liverpool | UK based Genesis Framework web designer and developer

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble