vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Update Usergroup using Php Script if email already exist (https://vborg.vbsupport.ru/showthread.php?t=286265)

warmarks 08-03-2012 11:14 AM

Update Usergroup using Php Script if email already exist
 
Hi,

I am trying to update usergroup of a given user whose email is known in $email variable.

PHP Code:

<?php 
define
('VB_AREA''External');  
define('SKIP_SESSIONCREATE'1);  
define('SKIP_USERINFO'1);  
define('CWD''/home--path');  
require_once(
CWD '/includes/init.php');  
// Data from Form Submision for VB 


$email  $_GET["email"]; 
$usrgrp $_GET["usergroupid"];

Can you please guide me what code i need to add in there...
so that if a user with $email is member of any usergroup before, i can add him to usergroup 3
also when $usrgrp=3,

i mean i know the email of the useraccount, and want to add him to additional usergroup (not removing from the existing ursergroups) i am using above php code from a non-vb page.

Looking forward to receive some help in this regard.

Thank you!

kh99 08-03-2012 10:46 PM

What you want to do is update the membergroupids field in the user table, where the email field matches the email address you have. The membergroupids field is a comma-separated list of integers (groupids), so you might be able to do it with one UPDATE query (which would probably need an "if" in the query because you'd need a comma or not depending on whether the membergroupids field is empty). If you wanted to do "right", you'd probably want to read the field, explode it in to an array, add "3" if it's not already in the array, then implode it back to a list and do an update. (I looked in to it before and found that the vb code is pretty forgiving of what's in that field, so you you wanted to just add 3 to the list without checking for it already being there, it should work anyway).


All times are GMT. The time now is 01:34 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.01049 seconds
  • Memory Usage 1,714KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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