Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2016, 07:09 PM
Colossal31 Colossal31 is offline
 
Join Date: Mar 2015
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Usergroup Manager

Afternoon everyone,

Ok so I have run into a dilemma that I have been searching for a solution for. I need to be able to remove 12-18 users out of a Secondary usergroup. But I need to be able to leave people that have a specific profile field value of 1-3 to remain in that group for that many clears.

Example:
Usergroupids 25, 30, 45, and 50 needs all users removed except users with profile_field _12 having a value of 2 or greater staying.

In the above situation they do not get moved to a new usergroup it just removes them from this secondary usergroup. I have about 30 usergroupids that I have to do this to. If someone knows of a mod that will help with this or an sql query that will work for this please let me know. I am not sql savvy so I couldnt write one myself. The two times I tried i killed my site and had to restore using a backup. Also if someone does know a way to do it with SQL is there a way when the query is run to reduce the profile field 12 number by 1 so that once that number gets below 2 they will be removed from the usergroup as well.

Thanks for any and all assistance.
Colossal31
Reply With Quote
  #2  
Old 01-16-2016, 07:34 PM
Gio~Logist's Avatar
Gio~Logist Gio~Logist is offline
 
Join Date: Jun 2004
Location: San Francisco
Posts: 2,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it's only 12-18 why not do it manually?
Reply With Quote
  #3  
Old 01-16-2016, 07:49 PM
Colossal31 Colossal31 is offline
 
Join Date: Mar 2015
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is 30+ Usergroups. That is only one set because there is 5 other sets of 30 Usergroups some with more and some with less users that are on different time frames. If i have the query with the basic knowledge of SQL that I have I am sure I can adjust it to work for the other usergroups I was just trying to keep the post short and to the point of what I need.

But I suppose I should have stated I need this for more than just the initial 30+ usergroups. I run a sports league with multiple sports. Each Sport has 30+ teams(which means UG for each team) depending on the sport and each team varies in size of 12 to 18 people(Users in those UGs). I need to be able to clear the Usergoups of their members because next season that usergroup may have 12 new people because of the way our leagues work. And the Profile_Field_12(not the actual field) is a retainer field. So a 12 year old can play in the 12-14yr old league for 3 years so the profile field 12 says he has 3 years he is eligible to be in that league.

I hope the additional info makes this easier to understand my need.

Thanks for your time,
Colossal31
Reply With Quote
  #4  
Old 01-16-2016, 08:01 PM
Gio~Logist's Avatar
Gio~Logist Gio~Logist is offline
 
Join Date: Jun 2004
Location: San Francisco
Posts: 2,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sorry, I would need to see it in front of me in order to make sense of it. I can definitely give you the query I THINK it should be, but I could be wrong.

Example:
Code:
UPDATE user
LEFT JOIN
        userfield on (user.userid = userfield.userid)
SET     user.membergroupids = ''
WHERE   !FIND_IN_SET(userfield.fieldXXXX,'1,2,3')
That basically says clear a user's secondary usergroups, if the user's fieldx is not 1,2 or 3

Again, this is my guess as to what you want, so use at your own risk.
Reply With Quote
  #5  
Old 01-16-2016, 08:16 PM
Colossal31 Colossal31 is offline
 
Join Date: Mar 2015
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok what do you not get maybe I can explain it better
Reply With Quote
  #6  
Old 01-16-2016, 08:20 PM
Gio~Logist's Avatar
Gio~Logist Gio~Logist is offline
 
Join Date: Jun 2004
Location: San Francisco
Posts: 2,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does my explanation of the code sound as though it's what you're looking for?
Reply With Quote
  #7  
Old 01-16-2016, 08:25 PM
Colossal31 Colossal31 is offline
 
Join Date: Mar 2015
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It sounds like that code will remove all secondary usergroups from a user. That is not what I am looking for. I just need to remove one secondary usergroup from all the users that are in it
Reply With Quote
  #8  
Old 01-16-2016, 08:36 PM
Gio~Logist's Avatar
Gio~Logist Gio~Logist is offline
 
Join Date: Jun 2004
Location: San Francisco
Posts: 2,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To make it remove just that secondary usergroup, try this:

Code:
UPDATE user
LEFT JOIN
        userfield on (user.userid = userfield.userid)
SET     user.membergroupids = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', user.membergroupids, ','), ',SECONDARYUSERGROUPID,', ','))
WHERE   !FIND_IN_SET(userfield.fieldXXXX,'1,2,3')
To be sure that it works the way you want, make a test user that it would effect, then get that user's id and change
Code:
WHERE   !FIND_IN_SET(userfield.fieldXXXX,'1,2,3')
to
Code:
WHERE   !FIND_IN_SET(userfield.fieldXXXX,'1,2,3') AND user.userid = USERIDHERE
This way it will only effect that user and you can see if its working correctly :up:
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:43 AM.


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.04308 seconds
  • Memory Usage 2,230KB
  • 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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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