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
There is is_a_guest() for if not logged in. A bunch of account related functions in include/functions_user.inc.php
Offline
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
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
include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
Offline
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
grml.. try
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
Offline
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
Sorry, no, I'm out of guesses.
Maybe @plg or another dev could chime in.
Offline
Thanks erAck for trying to solve this.
Hopfully @plg or another dev may have a solution.
Peter
Offline
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
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
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)
Offline