PDA

View Full Version : Making email optional


Disasterpiece
07-06-2011, 05:41 AM
Hello,

I am trying to develop an alternative login/authentication method.
For this, it's relevant that the user should not be forced to enter an email adress or a password.

Regular users should still be required to register with their email adress, which still gets validated if the admin chooses so.

The Problem I'm encountering is: When I create a new user via datamanager, all values get validated, which is a good thing.
However, if the email remains empty and I try to save the new user object, it throws an error that the email isn't valid.

And the error message itself is in phrase context, so I can't let's say filter out the error "invalid_email", but I had to filter out the error message "<li>The email you entered is ..." depending on the current active language. This isn't a good way to do it I guess and still, the user object wouldn't be saved.

Also, many forum services build up on the email functionality, so it's crucial to control the case, if an user didn't enter an email adress and not breaking modifications which rely on that.

Currently, to set up a working prototype, I set the email from these specific users to the webmaster email adress, that way I can ensure them being valid and not bounce back any emails.

I'm still not sure what's the best way to handle it, since vB doesn't seem to offer any routines to make email adresses totally optional.

To elaborate a bit on what I'm trying to do:
I want to provide an open-ID sign in via Steam API which allows to quick-register and login with information/authentication provided by the steam account. Just like the Facebook Connect.
Usergroup A is a regular usergroup like it exists on any standard vbulletin installation.
Usergroup B is memebr of the same vb Usergroup (id if you will), it only differs in the fact, that a user from Usergroup B uses a different registration method (Steam Open-ID) than a User from Usergroup A, just like some users registering via registration form and some via facebook connect.
Usergroup A should be forced to enter a valid email adress and a password, where Usergroup B doesn't need to enter a password or an email adress, because they use another method to authenticate themselves with the forum.
For Usergroup B, it's optional to provide a password and/or email. If they choose so, they are able to login with the forum loginform too, and/or be able to use forum services which require email adresses like forum subscriptions, email notifications on new PMs and such.

So basically I want some user preferences to be active only for Usergroup A, others only for Usergroup B without unnecessarily complicating the forum flow.

Any ideas on this?

Disasterpiece
07-08-2011, 04:59 AM
34 hits and no reply?

Did'n I express myself very well?

vbresults
07-08-2011, 03:11 PM
Using a plugin on the register_addmember_process hook, call vB_DataManager::do_unset (http://members.vbulletin.com/api/vBulletin/vB_DataManager.html#do_unset) with "email" as the first parameter. Then, use vB_DataManager::set (http://members.vbulletin.com/api/vBulletin/vB_DataManager.html#set) to set a fake email address.

It should look something like this:

$userdata->do_unset('email');
$userdata->set('email', uniqid() . '@example.com');


After that you just need to remove the email input from the registration templates.

Disasterpiece
07-09-2011, 10:42 PM
Thanks for your reply.

However, if i enter a fake email, I run into problems with a few things.
First I need to try to disable the change email & password field since the user is able to see the fake dummy email adress otherwise.

Next would be to disallow him to use a subscription feature where vbulletin would send emails... And it doesn't seem like there's an option to disable forum email subscriptions for a certain usergroup.

Any way to handle this "cleanly" without breaking too much ?

Like a global hook before sending any emails and prevent that from certain usergroups as well als not displaying the change password/email fields at all?

vbresults
07-09-2011, 11:48 PM
If you don't want an email at all, change the second line to:

$userdata->set('email', null, false, false);


I think that should work, and it is the cleanest way to do it: the email field will be blank.

I highly doubt there is a hook as expansive and low-level as you describe. If you do anything very different than what was suggested, things will get complicated and not be even close to "clean". Nonetheless, if you decide to go another route, good luck friend. :)

Disasterpiece
07-10-2011, 02:36 PM
$userdata->set('email', null, false, false);
$userdata->set('email', '', false, false);
Throws an database error,
$userdata->set('email', "''", false, false);
however works. email is empty afterwards. Great!

Hope this won't cause too much trouble :s