vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Usergroup Manager (https://vborg.vbsupport.ru/showthread.php?t=321510)

Colossal31 01-16-2016 07:09 PM

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

Gio~Logist 01-16-2016 07:34 PM

If it's only 12-18 why not do it manually?

Colossal31 01-16-2016 07:49 PM

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

Gio~Logist 01-16-2016 08:01 PM

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.

Colossal31 01-16-2016 08:16 PM

Ok what do you not get maybe I can explain it better

Gio~Logist 01-16-2016 08:20 PM

Does my explanation of the code sound as though it's what you're looking for?

Colossal31 01-16-2016 08:25 PM

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

Gio~Logist 01-16-2016 08:36 PM

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:


All times are GMT. The time now is 11:30 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.01777 seconds
  • Memory Usage 1,723KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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