No announcement yet.

Trying to query only select usergroup's

  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to query only select usergroup's

    I'm trying to get a query to only pull usergroups that have been selected in an options menu. The setting option is named showroster_displayed_groups which I installed via a products.xml file:

    <settinggroup name="showroster" displayorder="65535">
    <setting varname="showroster_displayed_groups" displayorder="10">
    This isn't a permission to view thing, it is more like choosing which usergroups will be displayed.

    Here is the current query and it works fine, except I can't figure out how to only pull the usergroups I entered above:

    PHP Code:
    $users $db->query_read_slave(
        SELECT user.*, usergroup.usergroupid, usergroup.title, user.options, usertextfield.*, userfield.*, 
        IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid 
        FROM " 
    TABLE_PREFIX "usergroup AS usergroup 
        LEFT JOIN " 
    TABLE_PREFIX "user AS user ON(user.usergroupid = usergroup.usergroupid OR FIND_IN_SET(usergroup.usergroupid, user.membergroupids)) 
        LEFT JOIN " 
    TABLE_PREFIX "userfield AS userfield ON(userfield.userid = user.userid) 
        LEFT JOIN " 
    TABLE_PREFIX "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid) 
        LEFT JOIN " 
    TABLE_PREFIX "usertextfield AS usertextfield ON(usertextfield.userid=user.userid) 
    I know I need a WHERE option at the end, but I just haven't had any luck with anything I've tried.

    One thing I tried was to do a query on the $vbulletin->options['showroster_display_groups']:
    PHP Code:
    $displaygroups explode(','$vbulletin->options['showroster_display_groups']); 
    But, then I couldn't figure a way to compare that in the main query. I've also tried creating a new table in my database and then using that to compare within my query, but that just gave me database query errors.

    I hate to admit it, but I'm stuck. I would appreciate any help, even a suggestion in the right direction.

    Thank you for your time.

  • #2
    2nd Try

    I'm having way too much difficulty getting the query to work the way I want how about I try another route.

    I have the setting variable "showroster_displayed_groups" in my options menu. It has the default values of 19,13,24,20,17,18. Would the following code (which I posted above) read them into an array like I think it should?

    PHP Code:
    $displaygroups explode(','$vbulletin->options['showroster_display_groups']); 
    If so, since userinfo['usergroupid'] is a working array variable on my page, would I use a foreach control to pull out each number from my $displaygroups array and compare it to the userinfo?

    How could I write the foreach control to do that?


    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.