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
- » VirtueMart Shopper Group
VirtueMart Shopper Group
VirtueMart Shopper Group
I'm trying to show module 137 to a Shopper Group 7 and no module to all other groups. The code is as follows but it doesn't work...:
if ($user->usertype == "Registered") {
$id = (int)$user->id;
$query = "SELECT shopper_group_id FROM #__vm_shopper_vendor_xref " .
" WHERE user_id = '$id'";
$db->setQuery( $query, 0, 1 );
$row = $db->loadObject();
$groupid = $row->shopper_group_id;
if ($groupid == 7) return 137; /* for VM shopper group 7, use module 137 */
else return; /* for all other groups use no module */
}
Any suggestions:)??
Re: VirtueMart Shopper Group
Hi,
the basic code looks fine. A couple of things to check though:
1 - don't use the "jos_" prefix for database calls. Instead, prefix with "#__". Joomla is smart enough to convert that to the right prefix for your installation (remembering that when you install Joomla you should have set this to a unique prefix, right??)
Therefore:
$query = "SELECT shopper_group_id FROM #__vm_shopper_vendor_xref " .
" WHERE user_id = '$id'";
2 - if you're just searching for a specific group id, why not put that into the query? There are 2 reasons for this. One is that it makes the query more specific and hopefully quicker, and the second is that if the user is in more than 1 group, you should really loop through all the results to check all of them for the group you are checking for. If you restrict the results to only that group, then you don't need to do that.
Therefore:
$query = "SELECT shopper_group_id FROM #__vm_shopper_vendor_xref " .
" WHERE user_id = '$id' and shopper_group_id = 7 ";
Try that - it might make things work better.
Cheers,
Stephen
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » VirtueMart Shopper Group
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 2
- User Info:
- Total Users:
- 7660
- Newest User:
- marino9885
- Members Online:
- 1
- Guests Online:
- 238
- Online:
- marino9885
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked