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);
}


All times are GMT. The time now is 07:55 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.01190 seconds
  • Memory Usage 1,752KB
  • 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
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (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