1
Anonymous
how obtain id of group?
  • 2004/9/9 15:58

  • Anonymous

  • Posts: 0

  • Since:


Hi, i need obtain of group id and group name for a hack, but i do not understand, the class for call these option.

Thanks for your help.

2
Dave_L
Re: how obtain id of group?
  • 2004/9/9 16:11

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


If you know a group ID, you can get the group name. If you know a group name, you can get the group ID.

What do you want to do?

3
Anonymous
Re: how obtain id of group?
  • 2004/9/9 17:13

  • Anonymous

  • Posts: 0

  • Since:


i know a user name but i fix mi problem whit these code, but i not shure if correct.

$group = $xoopsUser->getGroups();
for($i = 0; $i <= $grupos.length + 1; $i++){
if($grupos[$i] == 4){
$ifCliente = 1;
}else{
$ifCliente = 0;
}
}

these is for permission a group 4 is restricted in some parts of the module who i hack

thanks

4
Dave_L
Re: how obtain id of group?
  • 2004/9/9 17:37

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


// Set $ifCliente to true if the current user is a member of group ID 4.

$ifCliente is_object($xoopsUser) && in_array(4$xoopsUser->getGroups());

5
Mithrandir
Re: how obtain id of group?

Maybe you should study the syntax first.

for($i 0$i <= $grupos.length 1$i++){

1. Your variable $grupos is different from $group
2. There are no methods on non-objects (a string or an array is not an object in PHP)
3. Even if it was an object, methods are called with -> not . (a dot)

so this should work:
$groups $xoopsUser->getGroups();
for(
$i 0$i count($groups); $i++){
    if(
$grupos[$i] == 4){
        
$ifCliente 1;
    }else{
        
$ifCliente 0;
    }
}

should work - or even better:
$groups $xoopsUser->getGroups();
$ifCliente in_array(4$groups) ? 0;

6
Dave_L
Re: how obtain id of group?
  • 2004/9/9 17:41

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Beat you by two minutes.

7
Mithrandir
Re: how obtain id of group?

AND took the anonymous user into account

/mesa impressed

8
Anonymous
Re: how obtain id of group?
  • 2004/9/9 18:03

  • Anonymous

  • Posts: 0

  • Since:


thaks the code

$ifCliente = in_array(4, $groups) ? 1 : 0;

is just i looking for mi work,

thanks for your time.

Login

Who's Online

431 user(s) are online (323 user(s) are browsing Support Forums)


Members: 0


Guests: 431


more...

Donat-O-Meter

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

Latest GitHub Commits