Support

  1. alfred100
  2. General
  3. Friday, October 30 2015, 08:47 AM
as i want to show users acl in profile and user list u told me to add this code:

$acl = JFactory::getUser()->getAuthorisedViewLevels();
$db=JFactory::getDbo();
$query=$db->getQuery(true);
$query->select('title')->from('#__viewlevels')->where('id in ('.implode(',',$acl).')');
$db->setQuery($query);
$accessLevels=$db->loadColumn();
$formattedAcl='<span class="label label-info">'.implode('</span> <span class="label label-info">',$accessLevels).'</span>';
echo '<div style="float:right">'.$formattedAcl.'</div>';



it works well but i want to mite public acl in all users profile and user list. for example i have 3 acl as : public- registered and pro. i just want to show pro acl in user profile and omit two others.

is it possible to do this?
admin Accepted Answer
Admin
Hi,
there are different way to do this:
1. remove not important ACL from $accessLevels array
2. check in $accessLevels array, if there are "pro" ACL then show only this.
  1. more than a month ago
  2. General
  3. # 1
alfred100 Accepted Answer
thanks for answering. is it possible to give me the right code as i don't know php well to do this.

i thinks first one is better because i will have other acl and not only pro. so please give me the right code for first solution if not work i will tell you
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
Hi,
you can use something like this:
$acl = JFactory::getUser()->getAuthorisedViewLevels();
$db=JFactory::getDbo();
$query=$db->getQuery(true);
$query->select('title')->from('#__viewlevels')->where('id in ('.implode(',',$acl).')');
$db->setQuery($query);
$accessLevels=$db->loadColumn();
$formattedAcl='';
$exclude=array('Public','Registered');
foreach($accessLevels as $accessLevel)
{
if(!in_array($accessLevel, $exclude))
{
$formattedAcl.='<span class="label label-info">'.$accessLevel.'</span> ';
}
}
echo '<div style="float:right">'.$formattedAcl.'</div>';


NOTE: this code is not tested and not supported
  1. more than a month ago
  2. General
  3. # 3
alfred100 Accepted Answer
thanks for your response. that works excellent
  1. more than a month ago
  2. General
  3. # 4
alfred100 Accepted Answer
Content Protected
  1. more than a month ago
  2. General
  3. # 5
alfred100 Accepted Answer
oh sorry but that code has problem. any user with different acl when logged in see others acl same as his acl. for example if logged in user is pro user then see all other users acl as pro
  1. more than a month ago
  2. General
  3. # 6
admin Accepted Answer
Admin
Yes, because my code is based on code that you have posted, to solve at first line replace this:
$acl=JFactory::getUser()->getAuthorisedViewLevels();

with this:
$acl=JFactory::getUser($this->data->id)->getAuthorisedViewLevels();
  1. more than a month ago
  2. General
  3. # 7
alfred100 Accepted Answer
thanks but not working. as i use this code acl appears but for all members show same acl
  1. more than a month ago
  2. General
  3. # 8
admin Accepted Answer
Admin
In our test site works, we simply put this code at profile page template (at line 15 of file components/com_jsn/view/profile/tmpl/default.php)
  1. more than a month ago
  2. General
  3. # 9
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.