Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

$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

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

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";

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: $users--usertype

Yep, that's it.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Posts this week:
1
User Info:
 
Total Users:
5339
Newest User:
trei50809
Members Online:
0
Guests Online:
139

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