Jump to content

Automatic Forum account creation


mark1million

Recommended Posts

Yeah I have given it a go and cant seem to get it to do anything. I feel some step by step instructions are needed for us not so PHP educated VA admins.

A forum is a big part of a VA, not just for help, but also for the particular VA community to share there experiances and offer there ideas for new routes, Hubs ect. ect. I feel the best scenario would be a very simple forum to be intergrated with PHPVMS but I dont think this is in the pipeline at all.

Link to comment
Share on other sites

I am exacly the same. I am also wanting to make a custom template but I don't have any of the software in either tutorials to do it with, neither the experiance. Then I am not sure how much coding this is going to need. I just hope its either no coding after that part about making it writable or the template or not too much coding. lol I have hit a brick wall so far. At least I have another un-sucessful, stuipid project I am trying. lol

Link to comment
Share on other sites

Hi guys,

I was having probs integrating the membership into SMF too, so one night last week I sat down with a mate who's a programmer and working from the original ForumRegister module code which Mark posted, we came up with the following code which seems to work ok.

[*]Step 1: Create a new folder in /core/modules called ForumRegister

[*]Step 2: In that folder create a new php file called ForumRegister.php

[*]Step 3: Copy and paste in the following code




<?php
class ForumRegister extends CodonModule
{
 
  public function __construct()
  {
      CodonEvent::addListener('ForumRegister');
  }
 
  public function EventListener($eventinfo)
  {
      if($eventinfo[0] == 'registration_complete')
      {

$userinfo = $eventinfo[2];


$fname = $userinfo['firstname'];
$lname = $userinfo['lastname'];
$pass = $userinfo['password1'];
$email = $userinfo['email'];
$code = $userinfo['code'];

$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");

$uinfo = mysql_fetch_array( $get_uinfo );


$str = $uinfo['pilotid'];
$pilot_id = str_pad ($str,4,"0",STR_PAD_LEFT);
$pilot_id = $code.$pilot_id;
$pilot_name = mysql_escape_string ($fname. ' ' .$lname);
$passsha1 = mysql_escape_string (sha1(strtolower($email) . $pass));
$passsalt = substr(md5(mt_rand()), 0, 4);
$email = mysql_escape_string($email);
$tm = time();

mysql_query("INSERT INTO smf_members (member_name, real_name, passwd, email_address, hide_email, id_group, time_offset, location, lngfile, validation_code, id_theme, is_activated, id_msg_last_visit, date_registered, password_salt) VALUES ('".$email."', '".$pilot_name."', '".$passsha1."', '".$email."', '1', '4', '', '', '', '', '0', '1', '1', '".$tm."', '".$passsalt."')");

$member_id = mysql_insert_id();
     
mysql_query("update smf_settings set value = '$pilot_name' where variable='latestRealName'");
mysql_query("update smf_settings set value = '$member_id' where variable='latestMember'");
      }
  }

}
?>

Save everything and try a signup from your VA site and all being well a new account will also be created in SMF :)

We modified the code so that some different variables were inserted into the SMF database and also included the queries that perform an update to show the latest member. In addition, the password salt line has also been included, as otherwise without this the new user would need to login twice to SMF to begin with in order for the salt to be created. This is now generated automatically by the extra lines in the code above.

The other thing we tweaked was the way of logging into SMF, as originally it used the fullname and pilot code. The code now uses the email address, so the pilot can use the exact same login as on the VA site.

Hope this helps you all, as I know it was a huge relief to me to finally get the memberships working together :)

Link to comment
Share on other sites

  • 1 month later...

Hi everyone

I have followed all the posts and have implemented the forum registration and it all work perfectly.

I am using phpBB 2 and here is my problem. I want to be able to send the country name to the forum databse, I can get the country code in easy enough, but just not the actual country name

here is my code completed (without teh country thingy as I cannot get it to work)

<?php
class ForumRegister extends CodonModule
{
   
   public function __construct()
   {
      CodonEvent::addListener('ForumRegister');
   }
   
   public function EventListener($eventinfo)
   {
      if($eventinfo[0] == 'registration_complete')
      {

$userinfo = $eventinfo[2];


$fname = $userinfo['firstname'];
$lname = $userinfo['lastname'];
$pass = $userinfo['password1'];
$email = $userinfo['email'];
$code = $userinfo['code'];
$countries = $userinfo['countries'];

$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");
//echo "Result Select: ".mysql_error()."<br>";
$uinfo = mysql_fetch_array( $get_uinfo );

$str = $uinfo['pilotid'];
$pilot_id = str_pad ($str,3,"0",STR_PAD_LEFT);
$pilot_id = $code.$pilot_id;
$pilot_id_klein = strtolower($pilot_id);
$passMD5 = md5($pass);
$tm = time();

$query = ("INSERT INTO phpbb_users (
              user_id, user_active, username, user_password, user_session_time, user_lastvisit, user_regdate, user_timezone, user_style,
              user_lang, user_dateformat, user_attachsig, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm,
              user_allow_viewonline, user_notify_pm, user_popup_pm, user_email, user_from)
              
		  VALUES($str, 1, '$pilot_id', '$passMD5', '$tm', '$tm', '$tm', 0.00, 2, 'english', 'D M d, Y g:i a',
		  1, 1, 1, 1, 1, 1, 1, 1, '$email', '$countries')");

$result = mysql_query($query) or die(mysql_error());


$query = ("INSERT INTO phpbb_groups
              (group_type, group_description, group_moderator, group_single_user)
               VALUES(1, 'Personal User', 0, 1)");

$result = mysql_query($query) or die(mysql_error());


$group_user_id = mysql_insert_id();

    $query = ("INSERT INTO phpbb_user_group
              (group_id, user_id, user_pending)
               VALUES('$group_user_id', '$str', 0)");
		   
    $result = mysql_query($query) or die(mysql_error());

//echo "Result: ".mysql_error()."<br>";
//print_r($userinfo);

      }
   }

}

Any help is greatly appreciated.

Link to comment
Share on other sites

  • Administrators

There isn't really a list, but it will be the same as the column names.

The quick trick that I still use for the variable names are var_dump or print_r...

print_r($userinfo);

And will give you a list of the members

Link to comment
Share on other sites

  • 2 months later...

This is what I get upon registering a new account:

Confirmation Sent

Thanks for registering for Fly Melita, you will be notified via email of your registration status.

Warning: mysql_query() [function.mysql-query]: Access denied for user 'flymelit'@'localhost' (using password: NO) in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 26

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 26

Result Select: Access denied for user 'flymelit'@'localhost' (using password: NO)

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 28

PilotID:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'flymelit'@'localhost' (using password: NO) in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 43

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 43

And this is the code I used:

<?php

class ForumRegister extends CodonModule

{

 

  public function __construct()

  {

      CodonEvent::addListener('ForumRegister');

  }

 

  public function EventListener($eventinfo)

  {

      if($eventinfo[0] == 'registration_complete')

      {

$userinfo = $eventinfo[2];

$fname = $userinfo['firstname'];

$lname = $userinfo['lastname'];

$pass = $userinfo['password1'];

$email = $userinfo['email'];

$code = $userinfo['code'];

//mysql_query("INSERT INTO phpbb_users (username, user_password, group_id, user_timezone, user_dst, user_lang, user_type, user_actkey, user_dateformat, user_style, user_regdate) VALUES ($userr, $pass, '2','1.0', '0','en','0','','d M Y H:i', '1', time())");

$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");

echo "Result Select: ".mysql_error()."<br>";

$uinfo = mysql_fetch_array( $get_uinfo );

//echo "Uinfo: ".$uinfo['pilotid'];

$str = $uinfo['pilotid'];

$pilot_id = str_pad ($str,4,"0",STR_PAD_LEFT);

$pilot_id = $fname.$lname.$code.$pilot_id;

$pilot_id_klein = strtolower($pilot_id);

//echo "Pass: ".$pass."<br>";

$passMD5 = md5($pass);

//echo "Pass MD5: ".$passMD5."<br>";

echo "PilotID: ".$str."<br>";

$tm = time();

mysql_query("INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id, user_timezone, user_dst, user_rank, user_lang, user_colour, user_type, user_actkey, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '9','0.0', '0', '2','en','0099FF','1','5BN4938HB2','D M d, Y g:i a', '2', '".$tm."')");

//mysql_query("INSERT INTO phpbb_users (username, user_password) VALUES ('".$pilot_id."', '".md5($userinfo['password'])."')");

//echo "Result: ".mysql_error()."<br>";

//print_r($userinfo);

       

      }

  }

}

?>

Link to comment
Share on other sites

  • Administrators

This should be a fixed up version, using the proper API calls

<?php
class ForumRegister extends CodonModule
{

public function __construct()
{
	parent::construct();
	CodonEvent::addListener('ForumRegister');
}

public function EventListener($eventinfo)
{
	if($eventinfo[0] == 'registration_complete')
	{

		$userinfo = $eventinfo[2];

		$fname = $userinfo['firstname'];
		$lname = $userinfo['lastname'];
		$pass = $userinfo['password1'];
		$email = $userinfo['email'];
		$code = $userinfo['code'];


		$uinfo = PilotData::GetPilotByEmail($userinfo['email']);

		$code = PilotData::GetPilotCode($uinfo->code, $uinfo->pilotid);
		$pilot_id = $fname.$lname.$code.$pilot_id;
		$pilot_id_klein = strtolower($pilot_id);

		$passMD5 = md5($pass);

		$tm = time();

		DB::query("INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id, user_timezone, user_dst, user_rank, user_lang, user_colour, user_type, user_actkey, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '9','0.0', '0', '2','en','0099FF','1','5BN4938HB2','D M d, Y g:i a', '2', '".$tm."')");			


	}
}

}
?>

Link to comment
Share on other sites

  • 2 months later...

This should be a fixed up version, using the proper API calls

<?php
class ForumRegister extends CodonModule
{

public function __construct()
{
	parent::construct();
	CodonEvent::addListener('ForumRegister');
}

public function EventListener($eventinfo)
{
	if($eventinfo[0] == 'registration_complete')
	{

		$userinfo = $eventinfo[2];

		$fname = $userinfo['firstname'];
		$lname = $userinfo['lastname'];
		$pass = $userinfo['password1'];
		$email = $userinfo['email'];
		$code = $userinfo['code'];


		$uinfo = PilotData::GetPilotByEmail($userinfo['email']);

		$code = PilotData::GetPilotCode($uinfo->code, $uinfo->pilotid);
		$pilot_id = $fname.$lname.$code.$pilot_id;
		$pilot_id_klein = strtolower($pilot_id);

		$passMD5 = md5($pass);

		$tm = time();

		DB::query("INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id, user_timezone, user_dst, user_rank, user_lang, user_colour, user_type, user_actkey, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '9','0.0', '0', '2','en','0099FF','1','5BN4938HB2','D M d, Y g:i a', '2', '".$tm."')");			


	}
}

}
?>

So this is the final answer to the phpBB3 integration? I really want to use something like this but I can wait until all the kinks have been worked out.

I really appreciate all the hard work everyone puts into phpVMS. I can mod the hell right out of phpBB2.x and 3.x but this phpVMS is REAL brand new to me.

If I do use this, I create that folder in the modules folder and insert the php doc that I create and then install a phpBB3 using the same database as phpVMS and thats it? When a new person registers it will create a phpBB3 account?

Or do I need to do something further in the Admin section of my phpVMS install? Sorry to sound like such a newb, but I really am here  ;D

Link to comment
Share on other sites

  • Administrators

So this is the final answer to the phpBB3 integration? I really want to use something like this but I can wait until all the kinks have been worked out.

I really appreciate all the hard work everyone puts into phpVMS. I can mod the hell right out of phpBB2.x and 3.x but this phpVMS is REAL brand new to me.

If I do use this, I create that folder in the modules folder and insert the php doc that I create and then install a phpBB3 using the same database as phpVMS and thats it? When a new person registers it will create a phpBB3 account?

Or do I need to do something further in the Admin section of my phpVMS install? Sorry to sound like such a newb, but I really am here  ;D

Welcome! And yep, that should be it! It hooks in using the EventListener() function, so no core code has to be touched to extend.

It may break in phpBB updates, or something might be nulled or wrong with the user created - I'm not sure. To be sure, it has to use the phpBB API, but I haven't had the time to search that out. There was another post around here where I grabbed it from, it might be worth skimming through that

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...