vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with is_member_of condition (https://vborg.vbsupport.ru/showthread.php?t=175564)

misterfade 04-08-2008 08:57 PM

Help with is_member_of condition
 
I have a custom table setup called 'sellers' and I want to query that table to get all the userid's from there, then match it with the userid's in the vbulletin user table, then see if they're part of specific usergroups.

I figure the easiest option would be to get the sellers userid's and then use it in a loop with is_member_of but what would be the correct syntax?

All I know is the basic:
PHP Code:

is_member_of($vbulletin->userinfo123

Any help would be appreciated. Thanks.

Boofo 04-08-2008 09:32 PM

if (is_member_of($vbulletin->userinfo, 1, 2, 3))
{
do this
} else {
do that
}

misterfade 04-08-2008 09:40 PM

Sorry, that's not what I mean.

What I'm wondering is if I can use that and at the same time match it with the userid's from my sellers table.

Something like this:
PHP Code:

if ($row['seller_userid'] = (!is_member_of($vbulletin->userinfo123))) 

I know that code doesn't make any sense but that's what I'm wondering. Or would I be better off just running a query across both tables to match up?

Farcaster 04-08-2008 11:08 PM

$vbulletin->userinfo contains an array of variables for the user who is viewing the page. Instead, you would need to create a userinfo array for your seller. You could do this by using the fetch_userinfo function (included in functions.php). Example:

PHP Code:

// this is going to add a query for every time you loop through.. not very good.
$seller_userinfo fetch_userinfo($row['seller_userid']);
if (!
is_member_of($seller_userinfo123)) {
    
// Do this if the seller is not in group 1, 2, or 3
} else {
    
// Do this if the seller IS in group 1, 2, 3


Personally though, I would not want to use this implementation because every loop through is going to require an additional query to get the sellers account information. Instead, I'd probably just join to the user table on the seller ID and use a WHERE clause like this:

[sql]WHERE (user.usergroupid IN (1,2,3) OR user.membergroupids IN (1,2,3))[/sql]

You could also use that in a CASE statement in the SQL Query if you want to assign a particular value to a field that your program would read. Like this:

[sql]CASE WHEN (user.usergroupid IN (1,2,3) OR user.membergroupids IN (1,2,3))
THEN 1 ELSE 0 END) AS valid_seller[/sql]

Hope that helps...

misterfade 04-09-2008 10:56 AM

Farcaster,

You're right, that would be a big loop to do, so I'll try a join and see what I can come up with.

Thanks.


All times are GMT. The time now is 03:02 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.01026 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete