Shared emails

8 replies [Last post]
johnk
Offline
Joined: 11/01/2009
Status: 
Answered

Hiya,
There seems to be a problem using the Shared Email module with the membership module.
It spits out a bad SQL error when there is a duplicated address, then doesn't assign them a role. Just creates them without a membership.
Any creative solutions?
John

Leighton Whiting
Offline
Joined: 06/02/2009
John, Shared Email does some

John,
Shared Email does some pretty dangerous things in my opinion. Drupal is meant to have a 1 to 1 relationship between Users and Emails, and many modules count on that dependency. Since all that module really does is disable Drupal Core's security check to make sure that relationship holds, I won't be implementing the changes needed to work with a shared email environment. Drupal just isn't mean to run in a shared email environment.

Sincerely,
Leighton Whiting

johnk
Offline
Joined: 11/01/2009
more.

Hi,
I have tried to work around this by testing many other solutions with the members (~1000 new members per month, currently up to ~2500). One solution was including a secondary address field which does hourly exports to a mail server and then re-routes all mail sent to another domain to the secondary address. Meaning that people get the email address username@domain.com which is forwarded to their secondary address. This means that people who need to use a shared email address sign up using username@domain.com. This does not work for various reasons and often loses mail, but is what we have had to implement in the interim.

I suspect that many other paid membership sites may also need shared emails. One other project we are working on is a training site it will require individual user logins, but possibly one corporate email address. I understand what this means for password retrieval (possibly solved by the Shared Email Password Reset module). I understand that it may come with cavets about reduced functionality, but I will have to implement this custom in my own modules if I can't use shared email.

I know it is a bit crap to put in special provision for specific modules, which may or may not be activated, but in this case I think it would be a huge enhancement. The fact that it breaks with other modules is less a consideration because people implementing shared email take on this risk inherently.

I have not looked into membership to find out exactly why it breaks, but I don't want to create a custom patch every time you bring out new and awesome features.

That said. I will if there is no other way because right now it is seeming like it is absolutely required.

If it is a really hard change and you really don't have the time for it I will go ahead and spend the time, but if it is not so hard conceptually to allow provision of shared emails, it would be a major benefit.
John

Leighton Whiting
Offline
Joined: 06/02/2009
John, The part that requires

John,

The part that requires the change would be the ms_membership_ms_order_assign_user() function. This function attempts to create a new user account based on the information that the user entered in the registration form. There are two problems

1) The user account is loaded by the email they entered to see if the user account was created successfully or not. This could probably be changed to a better way of loading the user, but I can't think of any right now (my brain's kind of fried right now). The code currently used is:

$account = user_load(array('mail' => $product->data['form']['mail']));

 

2) The user account is created by passing the values the user entered into the registration form to the 'user_register' form submit function. The problem here is that the Shared Emails module (I believe) overrides the validate function for the registration form so that it won't return an error when the user uses an email which is already associated with an account. This is not carried through in this case, so the check is still made and the form does not pass validation. I suspect this would be a problem for all modules which try to programmatically create a user while using Shared Emails. The line that is relevant is here:

$error = drupal_execute('user_register', $form_state);

I hope that helps you get started.

Sincerely,

Leighton Whiting

 

johnk
Offline
Joined: 11/01/2009
Maybe: $account =

Maybe:

$account = user_load(array('uid' => db_result(db_query("SELECT uid FROM {ms_orders} WHERE oid = %d",$product->oid))));

?

johnk
Offline
Joined: 11/01/2009
hmmm, but its not set at that

hmmm, but its not set at that point is it?

Leighton Whiting
Offline
Joined: 06/02/2009
I was able to replace that

I was able to replace that code with the following:

$temp_account = $form_state['user'];
$account = user_load($temp_account->uid);

The only thing now is getting the shared emails override to work for programmatically submitted forms as well. This may be possible by hook_form_alter in a custom module...

Sincerely,

Leighton Whiting

johnk
Offline
Joined: 11/01/2009
Thanks Leighton, That seems

Thanks Leighton,
That seems to have worked.
Will you change that in your trunk?
John

Leighton Whiting
Offline
Joined: 06/02/2009
John, Yes, it has been

John,
Yes, it has been changed in the dev version, and will be rolled into the next release.

Sincerely,
Leighton Whiting

Twitter Feed