Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » $users--usertype
$users--usertype
$users--usertype
Hi stephen, I am trying the following code in an admin menu set to "special Access" in joomla core, but it still appears to "author" group users.
I tried the same with the joomla core set to "public access" for the same module and it did not work either.
Code:
//if users are on a given template the module will only appear to administrator or super administrators
$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();
if ($template == "electric_standard_jan2011" && $user == "Administrator" || "Super Administrator") return "208";
if ($template == "femmes_jan2011" && $user == "Administrator" || "Super Administrator") return "208";
if ($template == "flamencofusion_internationnal_jan2011" && $user == "Administrator" || "Super Administrator") return "208";
if ($template == "leadguitar_internationnal_jan2011" && $user == "Administrator" || "Super Administrator") return "208";
if ($template == "metal_jan2011" && $user == "Administrator" || "Super Administrator") return "208";
if ($template == "jw_clean_pro" && $user == "Administrator" || "Super Administrator") return "208";
Cheers,
Alex
Re: $users--usertype
Hi Alex,
it's just a PHP syntax thing. If you want to check for more than 1 value for a variable you can't do this:
if ($template == "electric_standard_jan2011" && $user == "Administrator" || "Super Administrator") return "208";
Instead you have to do this:
if ($template == "electric_standard_jan2011" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator")) return "208";
Repeat this pattern for the other statements as well.
Note the use of brackets to surround the "or" part of the statement, and use of $user->usertype instead of just $user.
Cheers,
Stephen
Re: $users--usertype
Solved! Thanks
Code:
$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();
if ($template == "electric_standard_jan2011" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator" || $user->usertype == "Manager")) return "208";
if ($template == "femmes_jan2011" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator" || $user->usertype == "Manager")) return "208";
if ($template == "flamencofusion_internationnal_jan2011" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator" || $user->usertype == "Manager")) return "208";
if ($template == "leadguitar_internationnal_jan2011" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator" || $user->usertype == "Manager")) return "208";
if ($template == "metal_jan2011" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator" || $user->usertype == "Manager")) return "208";
if ($template == "jw_clean_pro" && ( $user->usertype == "Administrator" || $user->usertype == "Super Administrator" || $user->usertype == "Manager")) return "208";
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » $users--usertype
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5965
- Posts this week:
- 4
- User Info:
- Total Users:
- 8011
- Newest User:
- ignac84502
- Members Online:
- 0
- Guests Online:
- 264
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked