joomla user group

  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 82
  • Thank you received: 0

mrperfectpz created the topic: joomla user group

Is there a way of adding current users usergroup in a textfield
#239132
  • Posts: 2986
  • Karma: 104
  • Thank you received: 394

mihaela replied the topic: joomla user group

Hello,

Here is how you can autofill a gorm field with a user group.

Go to the Advanced properties of your form > More options > Form pieces and in the Before Form section set Type to Custom.

In the code area that appears below put the following code:
$this->execPieceByName('ff_InitLib');

$user = JFactory::getUser(); 
$user_id ="$user->id"; 

if($user_id == '0' ) {
    $group_id = 0;
    }
else {
    $db = JFactory::getDBO();
    $db->setQuery("SELECT group_id FROM #__user_usergroup_map WHERE user_id =". $user_id);
    $group_id = $db->loadResult(); 
    }

ff_setValue('usergroupid', $group_id);
What this will do is it will fill in a form field named "usergroupid" with the ID of the user group that the user filling in the form belongs no.
You can change the Name of the "usergrouopid" field to whatever you want, just make sure to change it in the code.

Note that the user has to be logged in when filling in the form in order for this to work.

If you wish to display the title of the user group which user belongs to instead of the if of the group, here crosstec.org/en/forums/3-breezingforms-f....html?start=12#93487 you can find an explanation on how to do so.

Let me know whether this is working as you wanted.

Regards,

Mihaela
#239178
  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 82
  • Thank you received: 0

mrperfectpz replied the topic: joomla user group

Thanks works perfect !!

Can I turn off sections based on a usergoup ID = certain number ?
#239257
  • Posts: 2986
  • Karma: 104
  • Thank you received: 394

mihaela replied the topic: joomla user group

Hello,

I'm glad that this is working for you. :)

Yes, it is possible to do so.

Here are instructions crosstec.org/en/support/online-documenta...f-conditionally.html on how to turn sections on and off depending on value entered in a form.

Let me know whether you have managed to apply this to your form.

Regards,

Mihaela
#239271
Moderators: ForumSupporttomeperica
Time to create page: 0.066 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here