Jump to content

Recommended Posts

Posted

PHPVMS User Activation Module

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Author: Daniel Hill

Date: 28 May 2009

Version: V1.2

Description:

------------

This module allows pilots to verify their accounts themselves.

File Information:

-----------------

RegistrationData.class.php - Default file, for use if you have installed previous versions of this module.

email_registered.tpl - contents of this file is what is sent in the regisration e-mail.

MemAprv/MemAprv.php - this file activates the account and echo's a succesfull validation message with a link to the login file.

How to Install:

---------------

1. Copy email_registered.tpl to your current skins folder found here: /lib/skins/YOUR SKIN

2. Copy the entire MemAprv folder to your /core/modules folder.

If you have not installed any previous versions of this modules then installation is complete if you Have installed V1.0 or V1.1 continue:

3. copy "RegistrationData.class.php" to your "core/common" folder. NOTE. this will overwrite this file, only accept if the only modification to this file is from a previous installation of this module.

All done.

Now when a pilot registered they will be sent an e-mail with a link that once clicked will take them to the module, activating their account and giving them a link that redirects to the Login page.

Please note this module does not disable the option for Admins to activate a pilots account.

Support

-------

Support will be provided as and when possible via the thread on the PHPVMS forum (http://forum.phpvms.net/index.php?topic=862.0), please be advised i do run my own VA therefor it may take me some time to answer some support requests.

Release Notes

-------------

V1.0 - First Release

V1.1 - Second Release, Fixed a problem with the activation e-mail not including the pilots id, which would results in the activation not working.

V1.2 - Third Release, completely recoded the module so there are no longer any manual database querys, all modifications to pilots are done via existing functions, making it 100% compliant with PHPVMS updates.

Credits

-------

Nabeel - PHPVMS Author, Without the incredible amount of support and patience this module would not exist.

Notice: It is advised anyone who has installed V1.0 or V1.1 updates their installation with V1.2 Now Available below, to ensure 100% compliance with PHPVMS updates.

Pilot Activation V1.2.zip

Posted

Thanks for youe efforts :) I have downloaded and installed on my site. All emails with links and messages work fine, but admin still had to approve in the backend before pilot was allowed to sign in succesfully. Is this whats suppose to happen?

Posted

hmm, i never had that problem when i tested it, i know it still leaves the ability for admin to approve but once user activates it should allow them to log in correctly etc.

i'll install a test installation of PHPVMS and try it see what happends.

my replys might be late today, as im off to work in an hour.

What version of PHPVMS are you using, the latest full build or Beta?

Posted

Ok problem solved, there is a small modification required to "core/common/RegistrationData.class.php"

1. Find the following code:

public static function SendEmailConfirm($email, $firstname, $lastname, $newpw='')
{
	/*$firstname = Vars::POST('firstname');
	$lastname = Vars::POST('lastname');
	$email = Vars::POST('email');*/
	$confid = self::$salt;

	$subject = SITE_NAME . ' Registration';

	Template::Set('firstname', $firstname);
	Template::Set('lastname', $lastname);
	Template::Set('confid', $confid);


	$message = Template::GetTemplate('email_registered.tpl', true);

	//email them the confirmation
	Util::SendEmail($email, $subject, $message);
}

2. Replace with:


public static function SendEmailConfirm($email, $firstname, $lastname, $newpw='')
{
	/*$firstname = Vars::POST('firstname');
	$lastname = Vars::POST('lastname');
	$email = Vars::POST('email');*/
	$confid = self::$salt;

	$subject = SITE_NAME . ' Registration';
	$getplid = "SELECT * FROM " . TABLE_PREFIX ."pilots WHERE firstname='$firstname' AND lastname='$lastname' AND confirmed='0'";

	$plid = mysql_fetch_array(mysql_query($getplid));
	$plid = $plid['pilotid'];

	Template::Set('firstname', $firstname);
	Template::Set('lastname', $lastname);
	Template::Set('confid', $confid);
	Template::Set('pilid', $plid);

	$message = Template::GetTemplate('email_registered.tpl', true);

	//email them the confirmation
	Util::SendEmail($email, $subject, $message);
}

3. Save and Close all files.

Now it should work 100%, Sorry about that :S

Readme in Download file has been modified to show code change required.

Posted

Great work. Tested and works fine. That should save a little time. Also gets around the problem of not being notified when a new pilot joins.

Thanks

  • Administrators
Posted

Hey,

Don't modify code directly for this, you can use the post_registration hook.

http://docs.phpvms.net/development/02_events_list#registration_complete

Scroll up on that page to see what to put in your module

That way, you don't need to touch the registration module code :)

If you look at the thread for the smf/phpbb integration, it's the same thing

And don't use SQL directly, there's a API function to do that - check my signature.

Good job though!

Doh! Just saw you were editing the API function. You can add a function in your module called "EmailConfirmation" or something, and call your customized email thing there. Makes it a bit cleaner for everyone, and updates don't wipe anything out

Posted

Thanks Nabeel, i've had a quick look and think i know what i need to do, i'll have a proper look tonight when i finish work.

i was thinking of using: GetPilotByEmail ( $email) but how do i use it?

$pilotdata = GetPilotByEmail ( $email);?

if so remind me how i get the id from that?

THanks

  • Administrators
Posted

No prob!

If you use that API hook, you'll have the pilot's info who just registered. If you look at this post:

http://forum.phpvms.net/index.php?topic=272.msg3972#msg3972

<?php
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'];

// THent heir ID

$pilotdata = GetPilotByEmail ( $email);

echo $pilotdata->pilotid
?>

That's all the information of the pilot who just registered

Posted

i haven't a clue what im missing here, but no matter what i try its not sending an e-mail from my module???

<?php
class MemAprv extends CodonModule
{

 	public function __construct()
   		{
      	 CodonEvent::addListener('MemAprv');
   		}
   
   		public function EventListener($eventinfo)
  		{
     	 if($eventinfo[0] == 'registration_complete')
    { 

	$userinfo = $eventinfo[2];


	$firstname = $userinfo['firstname'];
	$lastname = $userinfo['lastname'];
	$email = $userinfo['email'];

	// get the pilot ID

	$pilotdata = GetPilotByEmail($email);

	$pilid = $pilotdata->pilotid;

	$subject = SITE_NAME . ' Registration';
	$message = Template::GetTemplate('email_registered.tpl', true);

	mail($email, $subject, $message);
	}
	}
}
?>

  • Administrators
Posted

Actually, had an idea, why do you need to send a email on your own?

Just modify the default email to include that link to your module, which has the link o activate

  • Administrators
Posted

You have the confirmation ID available, perhaps that's a better way to send it, instead of the ID? Anyone can change the ID or spoof it. The confirmation ID is one time

  • Administrators
Posted

Don't do any manual queries:

This is kinda backwards, but the URL;

http://yoursite.com/index.php/yourmodule?confirmid=$confirmid

Replacing $confirmid with the right one, of course

<?php

$_GET['confirmid'] = $conf_id; // This will be from the URL above, you don't actually need this line
RegistrationData::ValidateConfirm();  // This is an old function, but still works

There used to be email confirmation, but that was disabled in favor of the admin confirmation

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...