• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

little php help needed

joit

Active Member
Hi,

I want to display some content just for certain user groups in an article. This worked great for guest user groups but it doesn't seam to work for others:
PHP:
{source}
<?php
$user = JFactory::getUser();
if ($user->get('vendor', 0))
{
// vendor
echo '<p>
jkhgjfdkhg
</p>';
}
?>
{/source}

Any ideas?

Thanks
Hannes
 
What do you expect to get with $user->get('vendor',0)?
Vendor is no column in #__users
 
You'll need to use either getAuthorisedGroups() or getAuthorisedViewLevels(), depending on whether you really mean "groups" or view levels.

So if you 'vendor' group is ID 123 ...

PHP:
$groups = JFactory::getUser()->getAuthorisedGroups();
if (in_array(123, $groups)) {
   // echo your stuff
}

If you really mean view levels, not groups (which is what you should use for controlling access), then just substitute getAuthorisedViewLevels() and the view level ID in the above.

-- hugh
 
Thanks guys, this works great!
the only problem is, that I have links to menus in my echo stuff and these links get kicked out. This is maybe a problem of sourcerer. Any idea how I could bring them back?

Edit: it seams that all kind of formatting gets killed
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top