vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Add User to Primary Usergroup Based on Value of Custom Profile Field (https://vborg.vbsupport.ru/showthread.php?t=82992)

Conner85 05-24-2008 09:04 AM

Someone needs to update this for 3.7 Gold. It's causing registration errors for my users.

oz_girl 05-27-2008 01:55 AM

This is perfect for my forums but is this 3.7 Gold compatible?

oz_girl 05-28-2008 09:02 AM

Anyone using this successfully on 3.7 gold or 3.7.1??

jpapadpapa 06-07-2008 12:40 AM

I, too, really need this for 3.7.1!

steven s 09-04-2008 05:42 PM

Quote:

Originally Posted by oz_girl (Post 1533867)
Anyone using this successfully on 3.7 gold or 3.7.1??

Quote:

Originally Posted by jpapadpapa (Post 1542739)
I, too, really need this for 3.7.1!

Just installed it on v3.7.3.

THANKS!
This is the answer I've been looking for.
It will automatically ban my spammers.

Edit: Also works on 3.7.4 p1

steven s 11-02-2008 11:29 AM

This is an old one but I love it.
Spammers usually enter the same number into my location profile field.
Bam, automatic ban. Just banned two more.
They have gotten past answering questions which I'm sure stops a few, and this mod is just another measure.

YESS 12-23-2008 07:40 PM

Thank you Amy this is exactly what my client needed to perfect their forums.

Now all I need to do is learn how to do something like this with a cron job so that users who are already registered can choose something in their profile to 'upgrade' their account and set their primary usergroup.

YESS 12-23-2008 11:22 PM

There we go, I went ahead and wrote a Scheduled Task that every 10 minutes would check for anybody in the primary group 'Registered users' with the custom profile field9 set to 'Yes' and move them to usergroup 9, and vice versa. Sorry in advance for unclean code and please don't hate.

Place the code in the box below in a .php script in your /includes/cron folder and create a new scheduled task pointing to that script.

Replace 'field9' with the field you want to check. Replace 'Yes' and 'No' with the values of your field9 option.

Replace 'New member' and 'Introductory grower/distributor' with your chosen user titles.

Replace the usergroup numbers 2(Registered member) and 9(Custom usergroup) on the MySQL queries with the numbers of the usergroups you want to migrate to and from.

Sorry I can't go into more detail, sort of in a hurry to get this job done for my client. I don't recommend attempting this if you are not comfortable editing SQL queries.

Be sure to test this out on your forums using the 'Run now' option from the Scheduled Tasks section of the control panel, if you have messed up the syntax at all the control panel should return an error and send a copy of the error to the board owner via email.

I recommend backing up your databases before trying this out just in case you do something wrong, I don't hold any responsibility for lost or corrupt data in your database.

P.S. I recommend putting a notice in your custom usergroup description letting the user know that it can take up to 10 minutes for the changes to take effect to avoid confusion. (Or whatever interval you set your scheduled task job to.)

PHP Code:

<?php
error_reporting
(E_ALL & ~E_NOTICE);
if (!
is_object($vbulletin->db))
{
    exit;
}

$tmpA $vbulletin->db->query_read("
SELECT user.userid,user.usergroupid,user.username 
FROM `user`,`userfield` AS field 
WHERE user.usergroupid = 2 
AND user.userid=field.userid 
AND field.field9='Yes'
"
);

while (
$tmpU $vbulletin->db->fetch_array($tmpA))
{
    
$vbulletin->db->query_write("
        UPDATE " 
TABLE_PREFIX "user
        SET usergroupid = 9, usertitle='Introductory grower/distributer' 
        WHERE userid = " 
$tmpU['userid']);
}




$tmpA $vbulletin->db->query_read("
SELECT user.userid,user.usergroupid,user.username 
FROM `user`,`userfield` AS field 
WHERE user.usergroupid = 9 
AND user.userid=field.userid 
AND field.field9='No'
"
);

while (
$tmpU $vbulletin->db->fetch_array($tmpA))
{
    
$vbulletin->db->query_write("
        UPDATE " 
TABLE_PREFIX "user
        SET usergroupid = 2, usertitle='New member' 
        WHERE userid = " 
$tmpU['userid']);
}
?>


forexforum 01-21-2009 02:44 PM

Hi there,

Does it work on the latest vB 3.8? I need this. Thank you all. :confused:

amjadz4 03-29-2009 05:09 PM

i need this for the latest vb too!! can you please update it!!
thanks!


All times are GMT. The time now is 10:50 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.01417 seconds
  • Memory Usage 1,751KB
  • 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
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete