I used to use this code to control access in V3
it worked great but now when i use it in V4 it just acts as a redirect, so even when a user is logged in it still redirects them.
any one have a fix for this?
<?php
$user =& JFactory::getUser();
if ( !$user->gid ) {
$mainframe =& JFactory::getApplication();
$mainframe->redirect('index.php', 'You are not allowed to access this page', 'error');
}
?>
it worked great but now when i use it in V4 it just acts as a redirect, so even when a user is logged in it still redirects them.
any one have a fix for this?
Hi darrenhallinan ,
It looks as though the code has changed in Joomla! 1.6/1,7 because users can now belong to more than one group. I think $user->groups or $user->getAuthorisedGroups() will get you an array of groups. So count($user->groups) will be zero if they are not authorised in any group.
On the other hand maybe you could just check $user->id - that will be zero for guests.
Bob
It looks as though the code has changed in Joomla! 1.6/1,7 because users can now belong to more than one group. I think $user->groups or $user->getAuthorisedGroups() will get you an array of groups. So count($user->groups) will be zero if they are not authorised in any group.
On the other hand maybe you could just check $user->id - that will be zero for guests.
Bob
Hi bob
thanks for your replay as always, I really wish I could follow what you were explaining. . .
are you suggesting something like:
The above code does not work! - (for anyone looking for the same fix)
I have to say I am getting into the swing of V4, slowly but the one thing I loved about CC was the way it delt with users and groups. I wonder why max never brought that over to V4?
thanks for your replay as always, I really wish I could follow what you were explaining. . .
are you suggesting something like:
<?php
$user =& JFactory:getAuthorisedGroups();
if ( !$user->groups ) {
$mainframe =& JFactory::getApplication();
$mainframe->redirect('index.php', 'You are not allowed to access this page', 'error');
}
?>
The above code does not work! - (for anyone looking for the same fix)
I have to say I am getting into the swing of V4, slowly but the one thing I loved about CC was the way it delt with users and groups. I wonder why max never brought that over to V4?
I found what I was looking for .. .
in the wizard go to: Actions > Security > Authenticator
And add it to the onload. you can config to set to what groups you want to access it and what to do if they are not in that group.
That will do the job! Sweeeeet!
in the wizard go to: Actions > Security > Authenticator
And add it to the onload. you can config to set to what groups you want to access it and what to do if they are not in that group.
That will do the job! Sweeeeet!
This topic is locked and no more replies can be posted.