Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Check for multiple users
Page:
1
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,
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
Administrator has disabled public posting
Page:
1
- Index
- » MetaMod
- » MetaMod General Support
- » Check for multiple users
Board Info
- Board Stats:
- Total Topics:
- 1700
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 8056
- Newest User:
- no21an
- Members Online:
- 0
- Guests Online:
- 249
- 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