Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 23 Jan 2015, 20:14
Easelm Easelm is offline
 
Join Date: Mar 2009
Adding member to secondary usergroup via SQL query

I am working on an offsite script and everything is working fine, but I am
having some problems figuring out the best way to add a member to a
secondary usergroup if they are already in another through mysql query.

I understand I can simply update or insert my data directly in to the membergroupids field but I am
asking how I can do this if they are in another secondary usergroup already, since they list
separated by commas.

So what's the best way to execute a query where I can add the new groupid to
membergroupids if the member has more groups already or none?
Reply With Quote
  #2  
Old 23 Jan 2015, 20:23
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
You can do that with an IF/ELSE case in SQL:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Where 3 is the usergroupid.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.

Last edited by Dave; 23 Jan 2015 at 20:31.
Reply With Quote
  #3  
Old 23 Jan 2015, 20:59
Easelm Easelm is offline
 
Join Date: Mar 2009
Originally Posted by Dave View Post
You can do that with an IF/ELSE case in SQL:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Where 3 is the usergroupid.
Thanks, that makes it a lot easier for me


Update: Nice, it worked perfectly in my situation. Thanks again

Last edited by Easelm; 23 Jan 2015 at 21:07.
Reply With Quote
  #4  
Old 24 Jan 2015, 13:59
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
That's a great way. You can also select the membergroupids and then explode them into an array and add the ID you want and implode and insert again as well. You may have more flexibility if you're doing checks and balances with your update.

Google PHP:
implode();
explode();
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 10:09.

Layout Options | Width: Wide Color: