Can i use if logged in inside css ?

<?php if (!elgg_is_logged_in()) { ?>
img {
opacity:0.5;
}
<?php } ?>

Answered my own question sorry for that

maybe someone else finds this usefull

BTW p.s. sorry for my bad english (i'm from europe - lv)

  • Theoretically, yes (if you'll make CSS file with .php extention).

    But docs recommend to extend your CSS views:

    //FOR LOGGED IN USERS
    
    elgg_extend_view('elgg.css', 'theme/css');
    
    //FOR NON_LOGGED USERS
    if (!elgg_is_logged_in()) {
        elgg_extend_view('elgg.css', 'theme/my_css');
    }

    And in your my_css.php add your above code for images

  • my way works from layout.php anyways but you're way might be a better way to do this thanks for reply

  • Actually neither of these ways works very well if you have caching turned on.  The view extension will either be present or not depending on who was viewing it at the time the caches were built.

    The best thing to do is have a base of css that is loaded for everyone, then a second css file that is loaded conditionally.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking