MyBB Community Forums

Full Version: Register from another page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I'm currently working on a site, and I want it so that when register on the site, they'll also get registered on the forum.

I tried this, but it doesn't work:
            require_once "../www_forum/global.php";
            require_once "../www_forum/inc/functions_post.php";
            require_once "../www_forum/inc/functions_user.php";
            require_once "../www_forum/inc/class_parser.php";
            require_once "../www_forum/datahandlers/user.php";
            $userhandler = new UserDataHandler("insert");
            
            $user = array(
                "username" => $username, //these variables are set, don't worry xD
                "password" => $password,
                "password2" => $password,
                "email" => $email,
                "email2" => $email,
                "usergroup" => 2,
                "referrer" => 0,
                "timezone" => '0', 
                "language" => '', 
                "profile_fields" => '',
                "regip" => GetIP(), //get IP is a function which returns the IP
                "longregip" => my_ip2long(GetIP()),
                "coppa_user" => 0,
                "regcheck1" => "",
                "regcheck2" => "true"
            );
            
            $user['options'] = array(
                "allownotices" => 1,
                "hideemail" => 1,
                "subscriptionmethod" => 0,
                "receivepms" => 1,
                "pmnotice" => 1,
                "emailpmnotify" => 0,
                "invisible" => 0,
                "dstcorrection" => 1
            );
            
            $userhandler->set_data($user);
            
            $user_info = $userhandler->insert_user();
        }

Any ideas? Huh
Before inserting into the database, you must validate the user.

if($userhandler->validate_user()) {
	$user_info = $userhandler->insert_user();
} else {
	// handle errors
}
(2013-07-22, 10:45 AM)Shade Wrote: [ -> ]Before inserting into the database, you must validate the user.

if($userhandler->validate_user()) {
	$user_info = $userhandler->insert_user();
} else {
	// handle errors
}

Thanks for your reply. Wink
I tried this:
			if($userhandler->validate_user()) {
                $user_info = $userhandler->insert_user();
			} else {
			    echo "Something went wrong!";
			}

It doesn't display "Something went wrong!", but the User won't get registered. :/

Oh, I just found out, ANY code after
require_once "../www_forum/global.php";
won't get executed - but the file exists.

I have error_reporting set to E_ALL, but I don't get any error.


Got it working now. Smile