vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Add to Secondary Group based on email or IP (https://vborg.vbsupport.ru/showthread.php?t=117563)

RyanM 06-03-2006 07:24 PM

Add to Secondary Group based on email or IP
 
I have seen Add User to Secondary Usergroup Based on the Value of a Custom Profile Field at Reg. but am looking from something similar. I want if someone registers with an email from one of three domains or one of a list of IP address, the user will be added to a secondary usergroup. The original plugin looked like this.
Code:

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

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


                if ($user['field5'] == 'yes')
                {
                                        $membergroupids = $userdata->fetch_field('membergroupids');
                if ($membergroupids)
                {
                        $membergroupids = $membergroupids . ", 10";
                }
                else
                {
                        $membergroupids = 10;
                }

                $userdata->set('membergroupids', $membergroupids);                }]]></phpcode>
        </plugin>
</plugins>

So, I modified the phpcode in the plugin to not focus on one of the fields in userfield, but to look at email and ipaddress in user:
PHP Code:

$user $user $db->query_first("
            SELECT email, ipaddress
            FROM " 
TABLE_PREFIX "user
            WHERE userid = " 
$vbulletin->userinfo['userid'] . "
        "
);

        
$at_sign strpos($user['email'], "@");
        
$ip_array("123.123.123.123","123.123.123.124","123.123.123.125");
        
        if (
strpos($user['email'],"domain.com",$at_sign
        || 
strpos($user['email'],"domain2.com",$at_sign
        || 
strpos($user['email'],"domain3.com",$at_sign
        || 
in_array($user['ipaddress'],$ip_array))
        {
            
$membergroupids $userdata->fetch_field('membergroupids');
            if (
$membergroupids)
            {
                
$membergroupids $membergroupids ", 92";
            }
            else
            {
                
$membergroupids 92;
            }
            
$userdata->set('membergroupids'$membergroupids);
        } 

I am getting an error when I try to activate a user awaiting email confirmation (the hook).
Fatal error: Call to undefined function: () in /home/user/public_html/forum/register.php(930) : eval()'d code on line 9

Any help?


All times are GMT. The time now is 05:02 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.01045 seconds
  • Memory Usage 1,729KB
  • 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_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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