1
dplittle
Custom PHP Block Accessing Group Info
  • 2004/10/4 21:23

  • dplittle

  • Just popping in

  • Posts: 49

  • Since: 2004/9/15


I've built a custom PHP block that I'm using to dynamically create a "Quick Links" feature for my users. We need to access our internal site differently depending on if you are in front of or behind the firewall. This is all working great.

The next step though is to change the link depending on if the XOOPS user is in a specific group (i.e., "management" vs. "sales"). Is it possible somehow to have the custom PHP block be able to determine is the current user is in a specific group?

Thanks

David

2
Mithrandir
Re: Custom PHP Block Accessing Group Info

global $xoopsUser;
$groups = $xoopsUser ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);

if (in_array($group_id_you_want_to_check, $groups)) {
//show links
}

3
dplittle
Re: Custom PHP Block Accessing Group Info
  • 2004/10/5 16:04

  • dplittle

  • Just popping in

  • Posts: 49

  • Since: 2004/9/15


Quote:

Mithrandir wrote:
global $xoopsUser;
$groups = $xoopsUser ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);

if (in_array($group_id_you_want_to_check, $groups)) {
//show links
}


Thanks Mithrandir! I've got to spend some time in the developer documentation!

I'm having a problem getting all user groups though. When I run the following code ...

global $xoopsUser;
$groups $xoopsUser $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);

print_r($groups);


I only get the first three groups. Here's what I get as output ...

Array ( [0] => [1] => [2] => )


I know the user is in five groups ... the last two are the ones I'm using to check. Any ideas?

Thanks

David

4
dplittle
Re: Custom PHP Block Accessing Group Info
  • 2004/10/5 16:16

  • dplittle

  • Just popping in

  • Posts: 49

  • Since: 2004/9/15


Doh! Answered my own question ... I had to log out and back in first!

Thanks

David

5
dplittle
Re: Custom PHP Block Accessing Group Info
  • 2004/10/5 16:16

  • dplittle

  • Just popping in

  • Posts: 49

  • Since: 2004/9/15


Doh! Answered my own question ... I had to log out and back in first!

Thanks

David

6
dplittle
Re:Custom PHP Block Accessing Group Info
  • 2004/10/5 16:18

  • dplittle

  • Just popping in

  • Posts: 49

  • Since: 2004/9/15


And then I hit the Reply button twice!! Sorry.

Login

Who's Online

488 user(s) are online (64 user(s) are browsing Support Forums)


Members: 0


Guests: 488


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits