#1 2024-11-22 04:19:57

peterpix
Member
2015-06-14
68

Is user logged in function

Hi

I believe that this

( is_user_logged_in() )

is not a function that is used in Piwigo.

Can anyone tell me please what is the equivalent Piwigo function, that I could use in an if/else statement?

Peter

Offline

 

#2 2024-11-22 12:01:20

erAck
Only trying to help
2015-09-06
2183

Re: Is user logged in function

There is is_a_guest() for if not logged in. A bunch of account related functions in include/functions_user.inc.php


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2024-11-23 14:12:40

peterpix
Member
2015-06-14
68

Re: Is user logged in function

Thanks erAck

I used that function in this code in Local Files Editor:

<?php


if (is_a_guest()) {
    // Code for logged-out users
} else {
    // Code for logged-in users
    echo '<style>
        .navbar.navbar-contextual {
            display: none !important;
        }
    </style>';
}

?>

and I got this fatal error messsage:

Fatal error: Uncaught Error: Call to undefined function is_a_guest() in /home/u817514391/domains/peterpix.uk/public_html/local/config/config.inc.php:29 Stack trace: #0 /home/u817514391/domains/peterpix.uk/public_html/include/common.inc.php(79): include() #1 /home/u817514391/domains/peterpix.uk/public_html/index.php(11): include_once('/home/u81751439...') #2 {main} thrown in /home/u817514391/domains/peterpix.uk/public_html/local/config/config.inc.php on line 29

Apparently is_a_guest is an undefined function. Can you see what I am doing wrong?

Peter

Last edited by peterpix (2024-11-23 14:55:05)

Offline

 

#4 2024-11-23 15:04:06

erAck
Only trying to help
2015-09-06
2183

Re: Is user logged in function

As the file name and location suggests it's only available if include/functions_user.inc.php is included. For that, best include the include/functions.inc.php file that on turn includes several others, among them include/functions_user.inc.php, to make all needed functions available. So at the start of your code have

Code:

include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');

Running Piwigo at https://erack.net/gallery/

Offline

 

#5 2024-11-23 15:34:55

peterpix
Member
2015-06-14
68

Re: Is user logged in function

Thanks. I'm now getting the following fatal error:

Fatal error: Cannot redeclare micro_seconds() (previously declared in /home/u817514391/domains/peterpix.uk/public_html/include/functions.inc.php:33) in /home/u817514391/domains/peterpix.uk/public_html/include/functions.inc.php on line 33

Any idea how to fix that?

Offline

 

#6 2024-11-23 17:13:25

erAck
Only trying to help
2015-09-06
2183

Re: Is user logged in function

grml.. try

Code:

include_once(PHPWG_ROOT_PATH.'include/common.inc.php');

Running Piwigo at https://erack.net/gallery/

Offline

 

#7 2024-11-23 18:00:50

peterpix
Member
2015-06-14
68

Re: Is user logged in function

Thanks so much.

I tried that and got:

Fatal error: Uncaught Error: Call to undefined function is_a_guest() in /home/u817514391/domains/peterpix.uk/public_html/local/config/config.inc.php:33 Stack trace: #0 /home/u817514391/domains/peterpix.uk/public_html/include/common.inc.php(79): include() #1 /home/u817514391/domains/peterpix.uk/public_html/index.php(11): include_once('/home/u81751439...') #2 {main} thrown in /home/u817514391/domains/peterpix.uk/public_html/local/config/config.inc.php on line 33

Any more ideas that you have to fix this would be most welcome!

Peter

Offline

 

#8 2024-11-23 23:46:10

erAck
Only trying to help
2015-09-06
2183

Re: Is user logged in function

Sorry, no, I'm out of guesses.

Maybe @plg or another dev could chime in.


Running Piwigo at https://erack.net/gallery/

Offline

 

#9 2024-11-24 18:16:10

peterpix
Member
2015-06-14
68

Re: Is user logged in function

Thanks erAck for trying to solve this.

Hopfully @plg or another dev may have a solution.

Peter

Offline

 

#10 2024-11-27 04:36:17

peterpix
Member
2015-06-14
68

Re: Is user logged in function

This at least does not crash the site. I have used standard internal php to determine login status:

<?php

if (!$_SESSION['login'] && $_SESSION['login'] == "") {

}

elseif ($_SESSION['login'] == 1) {

  echo '<style>
        .navbar.navbar-contextual {
            display: none !important;
        }
    </style>';
 
}

?>

BUT the attempt to alter the css doesn't work - the element does not disappear when logged in. Can anyone help with code for the elseif section to change the css?

Peter

Offline

 

#11 2024-12-07 12:10:13

peterpix
Member
2015-06-14
68

Re: Is user logged in function

Hi all

I am concluding that there simply is no way to insert different css into a Piwigo site depending on whether a person is logged in or not, but if there is a way that anyone knows of please let me know.

Peter

Offline

 

#12 2024-12-07 12:48:49

Katryne
Member
2016-12-03
417

Re: Is user logged in function

The easy way is to use 2 different templates. Second one could be the first with a different name. And different settings, of course, to match the intended modified look for visitors.

When you config users, there are 2 tabs, one for registered users, the other for guest. Guest is for any visitor not logged.

When you edit Guest, there are 2 tabs. In the second one, you can choose a specific template, which will be compulsory for guests.

Last edited by Katryne (2024-12-08 09:45:58)


https://album.chauvigne.info/ v.15.1.0  PHP: 8.2.25
https://balades.comoni.org/  v.15.1.0 PHP: 8.2.25
Système d'exploitation: Linux - Hébergeur 1&1-Ionos - MySQL: 5.7.42
Bibliothèque graphique: External ImageMagick 6.9.11-60

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact