The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Feb 15, 2012 9:13 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Feb 15, 2012 6:25 pm
Posts: 1
I am going to make visible some objects (div,table) in my index.php file only for the one group of users, for example authors. I have inserted the following code:
Code:
<?php
$user =& JFactory::getUser();
?>
<?php if($user->get('usertype') == 'Author') : ?>
<div id="user1">
        <jdoc:include type="modules" name="user1" style="xhtml" />
</div>
<?php endif ?>

But it doesn't work. May be it is possible to identify the group by ID, but i am not in touch with php.


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 1:28 am 
Joomla! Explorer
Joomla! Explorer

Joined: Wed Jul 30, 2008 4:40 am
Posts: 278
Location: SC USA
Author group = 3
check with phpmyadmin for the table user_groups

_________________
Every Day Above Ground is a Good Day!


Top
 Profile  
 
PostPosted: Tue Feb 21, 2012 12:31 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 9:47 pm
Posts: 32
Location: Bogotá, Colombia
Hello,

actually I think you're using a deprecated attribute and you should change it. In Joomla! 1.5 you had only three groups, and users were supposed to belong to a single group, but ever since 1.6 there's a different mapping with user groups and access levels.

The easiest way to do something like that is to check if a user belongs to some specific group, like this:
Code:
if(in_array("8", $user->getAuthorisedGroups())){
// if user belongs to group with id=8, do this...
}


I guess it's not the best way (you should use ACL), but it'll work for you.

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group