I am working on a Joomla site and I want to display a verification graphic and text in their Profile when a User has completed a certain quiz in a program. I have most of the code complete, but I can't get it to do what I want. Here's what I have:
$db = &JFactory::getDBO(); $uri = JURI::base(); $my =& JFactory::getUser(); $user =& CFactory::getActiveProfile(); $query = 'select distinct(a.id), a.title, a.alias, a.description, a.created, a.responses, c.title as category' . ' from #__quiz_quizzes a left join #__quiz_categories c on a.catid=c.id left join #__quiz_responses r on a.id=r.quiz_id' . ' where r.created_by='.$user->id.' and a.published=1 order by a.created desc'; $db->setQuery($query, 0, 10); $items = $db->loadObjectList(); $menu = &JSite::getMenu(); $mnuitems = $menu->getItems('link', 'index.php?option=com_communityquiz&view=quiz'); $itemid = isset($mnuitems[0]) ? '&Itemid='.$mnuitems[0]->id : ''; if (strpos($itemid,'3')) { echo " Rep is Verified"; } else { echo " Rep is not Verified {SHOW_FOR profile_owner} How to get verified{/SHOW_FOR}{HIDE_FOR profile_owner} What does this mean?{/HIDE_FOR}"; echo ""; }
Trouble is, if anyone has taken test with id '3', it say they're verified. I need it to only display the verified part if the quiz_id is equal to '3', and if the created_by field matches the $user
. My code is taken from the original plugin and all of it may not even be needed for such a small function, help streamlining would be appreciated!
Screenshot of database table