Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Hide element if WordPress user logged in

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #285571
    harvey02
    Participant

    Hi, I am just curious if there is a css class that can hide an element if a WordPress user is logged in. I have some buttons that I only want shown if the user is logged out. I specifically need a class and not a custom function. Thanks!

    #285577
    LearnTheNew
    Participant

    i do not know what button you want to show up. But if the user is logged in the account should be with a job role example – subscribers. What you want to show for users you can edit it in code. but the WordPress backend should not be shown as frontend.

    #285996
    harvey02
    Participant

    I would like to hide/show a button in a slider. The slider buttons settings allow me to add css classes to the button.

    #286008
    Dagny
    Participant

    What you can do is use a function to add a class in the body if user is logged in. For example:

    https://pastebin.com/fSqv5g3p

    And then target the buttons you want to disable like this.


    .logged_in .button{
    display:none;
    }

    check if WP doesn’t automatically add classes on the body (or in any other parent) when the user is logged in where you can use them.

    #293014
    phil1ooo
    Participant

    Hello

    I have tried to place this into the Custom css panel but it doesn’t hide the block at all

    .logged-in #panel-gb130-5d2cbb5c140e9-1-0-0 > .panel-widget-style, #panel-gb130-5d2cbb5c140e9-2-0-0 > .panel-widget-style {
    display: none;
    }

    I am SiteOrigin Editor widget within this block/single row where I want to display a message on the front page and have it removed once they login.

    The above is copy/pasted from the browsers source for that block as far as I can see.

    Any ideas please on how to make this work please?

    Cheers

    #293018
    phil1ooo
    Participant

    It’s OK I worked it out and got it work as it should..

    Cheers

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.