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)

Oreamnos 10-30-2006 02:42 AM

Quote:

NOTE: This mod works for forums that require users to verify their email address upon registration. If your forum does not require users to verify their email address, you will need to use a different hook. If I have time, I'll test that variation.
OK, after I registered about 20 new test users here is what i found regarding this plugin's use with non-email verification registrations.

I tried almost every register_hook_name and none of them worked. it doesn't seem like it's possible to process this plugin without using the email verification function.

That being said, if you only want to move a user to another primary group on registration without a custom field being checked, you can still do this:

Add this:
PHP Code:

$userdata->set('usergroupid'11); 

(where 11 is the ID of the new primary usergroup)

Hook that with:
register_addmember_process

Activate and every member that registers on your site will have their primary group changed to ID: 11 (or whatever your choose)

i hope this info helps and saves some people a lot of time.

eric

DeMagH 11-27-2006 04:17 PM

it should be hooked correctly in my forums "using 3.6.2" but it doesn't seem to work
here is my code, please let me know if something is wrong: "i use field5 by the way"
Code:

if ($user['field5'] == 'Egypt')
{
        $userdata->set('usergroupid', 14);
}
if ($user['field5'] == 'Canada')
{
        $userdata->set('usergroupid', 18);
}
if ($user['field5'] == 'Saudi Arabia')
{
        $userdata->set('usergroupid', 15);
}
if ($user['field5'] == 'United Arab Emirates')
{
        $userdata->set('usergroupid', 16);
}
if ($user['field5'] == 'United Kingdom')
{
        $userdata->set('usergroupid', 17);
}
if ($user['field5'] == 'United States')
{
        $userdata->set('usergroupid', 10);
}
if ($user['field5'] == 'Other')
{
        $userdata->set('usergroupid', 19);
}

checked usergroupid matching
checked field matching
checked case sensitivity
is there anything else to check?!

note:
my field type is single selection menu, should i change it into radio buttons?

note:
here how the code is appearing in the plugins manager section:
Code:

// Get the value for field 5
        $user = $db->query_first("
            SELECT field5
            FROM " . TABLE_PREFIX . "userfield
            WHERE userid = " . $vbulletin->userinfo['userid'] . "
        ");


if ($user['field5'] == 'Egypt')
{
    $userdata->set('usergroupid', 14);
}
if ($user['field5'] == 'Canada')
{
        $userdata->set('usergroupid', 18);
}
if ($user['field5'] == 'Saudi Arabia')
{
        $userdata->set('usergroupid', 15);
}
if ($user['field5'] == 'United Arab Emirates')
{
        $userdata->set('usergroupid', 16);
}
if ($user['field5'] == 'United Kingdom')
{
        $userdata->set('usergroupid', 17);
}
if ($user['field5'] == 'United States')
{
        $userdata->set('usergroupid', 10);
}
if ($user['field5'] == 'Other')
{
        $userdata->set('usergroupid', 19);
}


DeMagH 11-29-2006 11:47 AM

bumping thread

amnesia623 11-30-2006 02:32 PM

does this work in 3.6.4?

amykhar 11-30-2006 06:43 PM

Yes. It's still running unchanged on my site.

wes_517 11-30-2006 11:00 PM

This is VERY close to exactly what my members are asking for, but I would need one small change...

Most of my site is closed off to non-members, and so to make sure who I am adding, I have to moderate all new users for privacy reasons...

So instead of adding new users directly to the group, what would I need to change to add them into the moderation queue instead?

I'm decent with PHP and Mysql, but still learning ins and outs of vbulletin...

any help?
--edit 1--
Thinking about this more, is that POSSIBLE for a primary group? (if the user logs in while their primary group is still under review, wouldn't they then not belong to ANY group and be denied access?)

--edit 2--

I hacked some code out, it may not be pretty, but it's working...

https://vborg.vbsupport.ru/showthrea...31#post1129131

since it modifies the secondary user, i posted it over there... anyone have an idea on the edit 1 question? can that be done or would it throw a fit because they wouldn't have a group yet?

salata 12-08-2006 01:36 PM

i am having diffulculty getting this to work for me, i am using 3.5.4

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
        <plugin active="1" product="vbulletin">
                <title>Put User In User Group Based on Field Value</title>
               
<hookname>register_activate_process</hookname>
                <phpcode><![CDATA[// Get the value for field 25
        $user = $db->query_first("
                        SELECT field25
                        FROM " . TABLE_PREFIX . "userfield
                        WHERE userid = " . $vbulletin->userinfo['userid'] . "
                ");


                if ($user['field25'] == 'No')
                {
                        $userdata->set('usergroupid', 36);
                }]]></phpcode>
        </plugin>
</plugins>


yingzhou 12-21-2006 06:19 AM

can this mod work on vb 3.6.x? Im using 3.6.4 now.

DeMagH 12-25-2006 05:37 PM

Quote:

Originally Posted by yingzhou (Post 1142661)
can this mod work on vb 3.6.x? Im using 3.6.4 now.

yeah worked for me in 3.6.2

Mum 01-12-2007 07:18 PM

I installed this, but when i registered a new user to test it, it hasn't added it to the group at all. This is my very first plug in, so may be something i've done wrong. PLease help :)

Quote:

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'Female')
{
$userdata->set('usergroupid', 11);

if ($user['field5'] == 'Male')
{
$userdata->set('usergroupid', 13);
}

DeMagH 01-16-2007 01:47 AM

after 2 months of using this with vbulletin v3.6.2 here is what is happening:
- most of the time it is working fine "80% of the time"
- sometimes instead of getting the user to the right group it gets him to REGISTERED "15%"
- sometimes the user fails to get the activation email "not sure if this is caused by this plug in or not, but this is the ONLY plug in hooked with user_activate_process" "5%"

This sample is taken from different 150 different registrations randomly from hotmail/gmail/yahoo/others users.

will disable it within 24 hours and wait for another month to see what will happen and if there will be any change in percentages given above.

salata 02-02-2007 02:38 AM

Quote:

Originally Posted by salata (Post 1134528)
i am having diffulculty getting this to work for me, i am using 3.5.4

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
        <plugin active="1" product="vbulletin">
                <title>Put User In User Group Based on Field Value</title>
               
<hookname>register_activate_process</hookname>
                <phpcode><![CDATA[// Get the value for field 25
        $user = $db->query_first("
                        SELECT field25
                        FROM " . TABLE_PREFIX . "userfield
                        WHERE userid = " . $vbulletin->userinfo['userid'] . "
                ");


                if ($user['field25'] == 'No')
                {
                        $userdata->set('usergroupid', 36);
                }]]></phpcode>
        </plugin>
</plugins>




Bump!!

wtrk 02-07-2007 05:58 PM

is there a way to do this to users after they have registered?

how can i force users who have already answered the question into the usergroup?

kall 02-19-2007 02:51 AM

Hey amy.. should this plugin work with NON custom profile fields? ie: default ones?

I have noticed a pattern with certain spambots, they always use 'Man' as field1.

Altering the plugin code to the following doesn't seem to work.

PHP Code:

// Get the value for field 1
        
$user $db->query_first("
            SELECT field1
            FROM " 
TABLE_PREFIX "userfield
            WHERE userid = " 
$vbulletin->userinfo['userid'] . "
        "
);


        if (
$user['field1'] == 'Man')
        {        
$userdata->set('usergroupid'8);
        } 

Any ideas?

Benj 03-30-2007 06:25 PM

any ideas if this works with the latest version ?

kall 03-30-2007 06:32 PM

Kinda.

Well, 90% of the time for me. :)

vuiveclub 04-18-2007 08:22 PM

Does this mod work in <hookname>register_activate_process</hookname> only?
I don't wanna use email for registration.

Medina 05-20-2007 05:49 PM

*notification*

Murty 05-29-2007 10:50 PM

Hey guys,

For those of you interested, a guy has created a modification that will move users to a specified usergroup depending on a profile field selection.
For me, when a user registers, they need to select whether they are male or female. Once they have registered, depending on whether they selected male or female, they get moved to the male or female user group i created.

You are able to get this mod by sending an email to: hugh@alaweb.com and requesting the 'user profile group modification'.
This mod was not made for free, so it will cost you $25.00 US.

I have tested it with vb 3.6.5 and it works great, highly recommend!

PM me if you want more info.

Medina 06-18-2007 08:23 AM

Quote:

Originally Posted by paulfletcher (Post 964433)
Hey. :) Well It was working for the secondary user-group. Although I found out that I needed one for the primary group. So Amykhar helped me out with this slight modification of the script... Works on my board (3.5.4).

PHP Code:

switch($userinfo['field5'])
{
    case 
"A":    
        
$userdata->set('usergroupid'12);
    break;
    case 
"B":
        
$userdata->set('usergroupid'13);
    break;
    case 
"C":
        
$userdata->set('usergroupid'18);
    break;


Talk to you later,
Paul F


Hello,

I have made it like this;

switch($userinfo['field5'])
{
case "Male":
$userdata->set('usergroupid', 30);
break;
case "Female":
$userdata->set('usergroupid', 29);
break;
}

and added beneath the the plugin


Quote:

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");

if ($user['field5'] == 'Male')
{
$userdata->set('usergroupid', 30);
if ($user['field5'] == 'Female')
{
$userdata->set('usergroupid', 29);
}
switch($userinfo['field5'])
{
case "Male":
$userdata->set('usergroupid', 30);
break;
case "Female":
$userdata->set('usergroupid', 29);
break;
}
Am I doing this right?

Thanks for a reply, of any advanced person with this script ;)

Medina 06-21-2007 01:19 PM

please, could somebody help me :(

any moderators/coders?

kjhkjh 10-03-2007 07:29 PM

I have imported this into 3.6.8 after the making the changes but my test users aren't being put into the correct groups based on their registration field selection.

Can anyone help?

This is a fresh install of vb and I have done the necessary changes as outlined in the instructions here? :(

If I can get it working it would save me a lot of work,

Thanks

vuiveclub 10-21-2007 06:18 PM

Can someone write cron something like this?
I mean automatic move to an usergroup if that user is Female? :)
Thanks

bschneider5 10-26-2007 10:57 AM

How can I do this with this mod.....

Spammers 99% of the time put a url in my FULL NAME field, and I would like to use this mod if possible. I installed it, and want any user that enters "http" in the FULL NAME field to be moved to the banned usergroup. This is the code I'm using but it doesn't work:
HTML Code:

// Get the value for field 6
        $user = $db->query_first("
                        SELECT field6
                        FROM " . TABLE_PREFIX . "userfield
                        WHERE userid = " . $vbulletin->userinfo['userid'] . "
                ");


                if ($user['field6'] == 'http')
                {
                        $userdata->set('usergroupid', 8);
                }


SVTCobraLTD 01-27-2008 03:03 PM

Is this still be supported? I tried installing on the board with no luck. 3.6.8pl2. Anyone?

vbob 02-02-2008 10:29 PM

Hi, It seems that you've got a very interesting mod here. :-)
I have Vbulletin 3.6.8 Patch Level 2
and vBadvanced CMPS v3.0 RC2 installed to my forum. Will it work to my forum or it works only with 3.5.x??? Should I try it?? Can you provide us with a 3.6.8 version that works for sure? (I haven't try it yet...because I am waiting for your answer first). :-)

Demo16 02-11-2008 05:42 PM

Can I use this mod to do this: all users that have EN language are automatically moved to usergroup: en_users

can I do this? I have also Vbulletin 3.6.8 Patch Level 2

Demo16 02-16-2008 08:15 AM

it doesn't work for me, any help?

wtrk 03-26-2008 09:01 PM

is there a way to move people who have already answered the question?

WNM07 05-15-2008 01:41 PM

i would like to incorporate this into my postbit using this as a base so that the admin can change the users primary usergroup from the postbit .. can't figure out how any idea?

PHP Code:

<if condition="$bbuserinfo[usergroupid] == 6">
<
tr><td class="vbmenu_option"><span onmouseover="this.style.cursor='hand';" onClick="window.open('modcp/banning.php?do=banuser&userid=$post[userid]','ban','width=500,height=375,scrollbars=yes')"><b>Ban User$post[username]</b></span></td></tr><tr><td class="vbmenu_option"><a href="moderator.php?do=useroptions&u=$post[userid]">Edit User$post[username]</a></td></if> 


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 04:15 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.01510 seconds
  • Memory Usage 1,878KB
  • 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)bbcode_html_printable
  • (5)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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