by eggsurplus

Control what your users can access and save time, money, and frustrations. Lock down sensitive data in SugarCRM or SuiteCRM to specific groups or teams. Supports unlimited assigned users, unlimited group assignments to records, custom layouts for each group, login/sudo capabilities and much more.

Free 30 day trial
Try it Now

By clicking you consent to share your profile with the developer

#3225 - Logic Hook How to know if a User is in a specific group

Closed General Question created by Lion Solution Verified Purchase 7 years ago

Hi, how can i test in a Logic Hook if a user "U1" is assigned to a Group "G1"?

  1. MayerElyashiv member avatar

    Lion Solution Verified Purchase

    7 years ago

    actually i mean the current user

  2. eggsurplus member avatar

    eggsurplus Provider Affiliate

    7 years ago

    There's a function in /modules/SecurityGroups/SecurityGroup.php called getUserSecurityGroups. If you pass the current user ID to it it will return all groups that the user is assigned to. You can then loop through those to see if in G1.

  3. MayerElyashiv member avatar

    Lion Solution Verified Purchase

    7 years ago

    Thank you Jason. I did it with

    require_once ('modules/SecurityGroups/SecurityGroup.php');
    global $current_user; 
    $user_id = $current_user->id;
    $groupArray = array();
    $groupArray = getUserSecurityGroups($user_id);
    foreach($groupArray as $group){
    

    ...

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      7 years ago

      Perfect. Did you mean SecurityGroup::getUserSecurityGroups($user_id)?

      Got it to work as needed?

    • MayerElyashiv member avatar

      Lion Solution Verified Purchase

      7 years ago

      exactly. Thanks. This solved me an issue,

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      7 years ago

      Great! I'll close this out for now.

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating
Rating