10 replies [Last post]
Wonder95's picture
Offline
Joined: 02/20/2008
Juice: 283

This may sound weird, but is there a way to keep Ubercart from automatically creating a Drupal user account when a new customer buys a product? I'm using CiviCRM on a site, and I added Ubercart with one product because the organization sells a DVD. However, since both modules use the Drupal user database and Drupal users are imported into CiviCRM, users (non-members) who buy a DVD automatically get imported to CiviCRM. Plus, the shipping just involves putting postage on an envelope and mailing it, and there is just one product, so maintaining a user account is not needed for non-members.

Thanks.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Way to disable Drupal user account creation?

In core, this isn't possible. Perhaps this can be abstracted so you can have differing order submit handlers... for the time being, you'll have to modify uc_cart.module in the function uc_cart_complete_sale(), but this is bad practice and I'd advise you to devise an alternate solution if at all possible.

Wonder95's picture
Offline
Joined: 02/20/2008
Juice: 283
No hook?

There's no way I can hook into that function (or process) and modify the flow at all?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: No hook?

Not that function specifically, though you can always try and bypass it using hook_form_alter() and a custom submit handler on the review order form. This is getting into Drupal ninja territory, though. Eye-wink

dharmatech's picture
Offline
Bug Finder
Joined: 01/28/2008
Juice: 94
Re: Re: No hook?

We have contributed a patch to accomplish this. The patch works with beta 7 and MySQL, but does not at the moment support PostgreSQL. You can download the patch here.

aewilliams's picture
Offline
Joined: 05/31/2008
Juice: 78
Still work?

Does this patch still work for the latest RC4 release?

haysuess's picture
Offline
Joined: 07/07/2008
Juice: 280
Re: Still work?

Does this patch work the the 1.0 release?

houdelou's picture
Offline
Joined: 06/01/2010
Juice: 9
Re: Way to disable Drupal user account creation?

Another way to do it is to go to page /admin/store/settings/checkout/edit/messages and add the foloowing code under "Checkout completion for new users" with php filter enabled that will delete the user after creating it :

<?php
user_delete
(NULL, [order-uid]);
?>

To do this, you have to install Token module. That way, the user will be removed automatically after being created !

scot.self's picture
Offline
Joined: 02/11/2010
Juice: 104
great solution!

This works great!! Great idea. Thanks.

screenage's picture
Offline
Joined: 04/26/2011
Juice: 3
Re: Way to disable Drupal user account creation?

Suppose an existing user (such as admin) is already logged in, I wonder if this user_delete function is really desirable? (I didn't test it, just wondering)

houdelou's picture
Offline
Joined: 06/01/2010
Juice: 9
Re: Re: Way to disable Drupal user account creation?

The code is under "Checkout completion for new users". Admin is not a new user but it would be a good idea to make sure the admin account doesn't get deleted !