TOPIC:

joomla user group 7 months 5 days ago #239132

  • Topic Author
  • mrperfectpz
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 257
  • Thanks: 0
Is there a way of adding current users usergroup in a textfield

Please Log in or Create an account to join the conversation.

joomla user group 7 months 1 day ago #239178

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
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

Please Log in or Create an account to join the conversation.

joomla user group 6 months 4 weeks ago #239257

  • Topic Author
  • mrperfectpz
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 257
  • Thanks: 0
Thanks works perfect !!

Can I turn off sections based on a usergoup ID = certain number ?

Please Log in or Create an account to join the conversation.

joomla user group 6 months 3 weeks ago #239271

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.049 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

Summer Sale!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

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!