Home » Forum
NoNumber!

Joomla! extensions & websites
development / support / consultancy

I try to respond within 24 hours (excluding weekends). If I haven't responded by then, feel free to post a reminder or bug me via email.
Welcome, Guest
Please Login or Register.    Lost Password?

show module based on php script
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: show module based on php script
#9486
show module based on php script 2 Months, 3 Weeks ago  
I have browsed through the forums and got some basic directions as to how to accomplish this. For some reason I am missing something, and I know it is a simple answer. I am not very proficient with php and still learning. Here is my code:

               $userid = $user->id;
$sql = "SELECT * FROM `jos_k2_users` WHERE `userID` = $userid";
$db =& JFactory::getDBO();
$db->setQuery($sql);
$result = $db->loadObject();
$k2group = $result->group;
return ($k2group==1);


I am using this in the PHP field under exclude selected. There is a menu that I want only k2 users with k2 id > 1 to be able to see, and it is set as registered so non-registered users cannot see using joomla permissions & default k2 group is 1. I also need to do the same for regular users, so basically only show where k2 id = 1.

I know its simple, just can't seem to get it to work the right way in advanced module manager. It displays the module regardless of k2 user group. The code works with a simple text link in the middle of the page, where it returns i have an if statement that I have tested and works.

any help is greatly appreciated, and I thank whoever has a few minutes to reply in advance
adam sikora
Posts: 3
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#9488
Re:show module based on php script 2 Months, 3 Weeks ago  
tried the following without any luck as well:


if ($k2group>1)
{
return (1);
}
else
{
return (0);
}
adam sikora
Posts: 3
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#9489
Re:show module based on php script 2 Months, 3 Weeks ago  
ok...i'm a tool. answered my own question. forgot to get the joomla user object, assumed it was already present. used this in conjuntion with returning true or false. hopefully this prevents somebody else from making the same mistake.
adam sikora
Posts: 3
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#9493
Re:show module based on php script 2 Months, 2 Weeks ago  
Great you figured it out
Peter van Westen
Admin
Posts: 4533
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
Go to topPage: 1
Joomla Open Source Training