$list_of_groups = array("FACULTY","STAFF");
foreach ($list_of_groups as $i => $group) {
$user_in_group = $adldap->user_ingroup($username,$group);
print "<h2>Group: ".$group." user in group? ".$user_in_group."</h2>"; // if 1, means yes
}
Need to print run the appropriate function based on what returns true.
There are user's that are members of both FACULTY and STAFF groups, so I want to check for those users and display the appropriate content for them.
So if the user is both faculty and staff, then display this, if they are only of staff, display that, same for faculty, might not make sense, but I will write out some code "in theory" that will help you understand what I am trying to do
switch(Get group membership of user) {
case "FACULTY":
print "Faculty group member";
break;
case "STAFF":
print "Staff group member";
break;
case "FACULTY and STAFF":
print "Member of both faculty and staff";
break;
}
I am unsure on how it will check if they are members of both groups and run that thru the case statement to display the appropriate message.
The foreach look currently runs thru every group the user belongs to, prints out the ones from the $list_of_groups and the number 1 to the right of it, signifying they belong to it. The problem I have is trying to use that information to run thru the case statement, I am unsure of how to go about that.
This is what it prints out for the user currently passed thru the foreach loop:
Group: FACULTY user in group? 1 Group: STAFF user in group? 1
Any help is appreciated.
EDIT: I apologize, I did not explain well enough. I need to run thru all the groups they belong to, if they belong to both Faculty and Staff, print "Belongs to Faculty and Staff", if only faculty print out "Faculty", if only staff print out "Staff", if only student, print out "Student", this is for displaying certain information based on what group the user belongs to. So the code would have to check all groups, I guess the list_of_groups is not needed, as they will find the group membership via $result=$adldap->user_groups("$username);.