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.

 

Check for multiple users

Check for multiple users

I want to enable modules based on username I found the recipe below and want to modify it for an array, for example,
bolson,jamie,admin,bob,frank,jim.

How would I alter this code?

Code:

$search_user_name = 'bolson';

$username = $db->getEscaped($search_user_name);
$query = "SELECT username "
. " FROM #__session WHERE username = '$username' "
. " AND guest = 0 "
. " AND client_id = 0 ;" ;
$db->setQuery( $query );
$found = $db->loadAssoc();
if (is_array($found)) return "17,43"; /* found him. customise to your own module number. */
return 43; /* didn't find him. Customise to your own module number. */

Thanks,

kencostore
Beginner Modder
ranks
useravatar
Offline
1 Posts
User info in posts
Administrator has disabled public posting

Re: Check for multiple users

Hi kencostore,

Assuming that you want the same module to show up no matter which of the users are logged in, try this:

Code:

$search_user_names = "('bolson','jamie','admin','bob','frank','jim')"; 

$query = "SELECT username "
. " FROM #__session WHERE username in $search_user_names "
. " AND guest = 0 "
. " AND client_id = 0 ;" ;
$db->setQuery( $query );
$found = $db->loadAssoc();
if (is_array($found)) return "17,43"; /* found him. customise to your own module number. */
return 43; /* didn't find him. Customise to your own module number. */

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
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10095
Newest User:
johnson58
Members Online:
0
Guests Online:
192

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