Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2004, 01:50 PM
Ocean's Avatar
Ocean Ocean is offline
 
Join Date: Mar 2004
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What Conditional do I need to specify *Secondary* User Groups?

If I want a section of code in a PHP file to apply to Administrators (Group ID 6) only, I might use the following conditional:


PHP Code:
 
if ($bbuserinfo[usergroupid]==6)
{
 


However, that conditional only works if the Primary User Group for a user is Group ID 6.

How does this conditional need to be modified so that it also works if a user's Secondary User Group is Group ID 6?


Thanks!
Reply With Quote
  #2  
Old 08-30-2004, 02:03 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$groups = fetch_membergroupids_array($bbuserinfo);
if(in_array(6, $groups))
{

}

or, if you want to combine...

$groups = fetch_membergroupids_array($bbuserinfo);
if(in_array(6, $groups) OR $bbuserinfo['usergroupid'] == 6)
{

}
Reply With Quote
  #3  
Old 08-30-2004, 02:14 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rake
$groups = fetch_membergroupids_array($bbuserinfo);
if(in_array(6, $groups))
{

}

or, if you want to combine...

$groups = fetch_membergroupids_array($bbuserinfo);
if(in_array(6, $groups) OR $bbuserinfo['usergroupid'] == 6)
{

}
OIr if your connected to vBulletin just use is_member_of
Reply With Quote
  #4  
Old 08-30-2004, 02:31 PM
Ocean's Avatar
Ocean Ocean is offline
 
Join Date: Mar 2004
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery

OIr if your connected to vBulletin just use is_member_of
Hi, Zachery! Out of curiosity, what do you mean by "if your connected to vBulletin"? Do you mean if I'm talking about the vB PHP files as opposed to generic PHP coding in general?

If so, than I can tell you that I am talking about the vB PHP files. And in that case, could you give me an example of the proper syntax to use with "is_member_of"?


Thanks!
Reply With Quote
  #5  
Old 08-30-2004, 02:32 PM
Ocean's Avatar
Ocean Ocean is offline
 
Join Date: Mar 2004
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rake

$groups = fetch_membergroupids_array($bbuserinfo);
if(in_array(6, $groups))
{

}

or, if you want to combine...

$groups = fetch_membergroupids_array($bbuserinfo);
if(in_array(6, $groups) OR $bbuserinfo['usergroupid'] == 6)
{

}
Hi, Rake! Thanks for replying! Out of curiosity, is there any reason to combine the two conditionals the way you did on your second example? Wouldn't the first one catch both Primary as well as Secondary groups?
Reply With Quote
  #6  
Old 08-30-2004, 02:43 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey Ocean.
Yes, you're right in fact. I was under the impression that the function only gets the secondary group ids, but it also fetches the primary group, by default
Code:
function fetch_membergroupids_array($user, $getprimary = true)
For the is_member_of function:

Code:
function is_member_of($userinfo, $usergroupid)
Reply With Quote
  #7  
Old 08-30-2004, 02:53 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Ocean
Hi, Rake! Thanks for replying! Out of curiosity, is there any reason to combine the two conditionals the way you did on your second example? Wouldn't the first one catch both Primary as well as Secondary groups?
IF you included vBulletins global.php you can use its functions

so is_member_of($var, x) will work
Reply With Quote
  #8  
Old 08-30-2004, 03:25 PM
Ocean's Avatar
Ocean Ocean is offline
 
Join Date: Mar 2004
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery

IF you included vBulletins global.php you can use its functions

so is_member_of($var, x) will work
This would be for code added to ShowThread.php and Misc.php - so I am assuming that there wouldn't be a problem, yes?

And that being the case, is this the proper syntax?


PHP Code:
 
if (is_member_of($bbuserinfo6)
{
 


Or am I formatting it wrong?
Reply With Quote
  #9  
Old 08-30-2004, 03:32 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

should be:

if (is_member_of($bbuserinfo, 6))
{

}
Reply With Quote
  #10  
Old 08-30-2004, 03:33 PM
Ocean's Avatar
Ocean Ocean is offline
 
Join Date: Mar 2004
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rake

should be:

if (is_member_of($bbuserinfo, 6))
{

}
I got caught by the trailing parenthesis! Thanks, rake and Zachery. I appreciate all of your help!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04350 seconds
  • Memory Usage 2,258KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete