Ubercart/Signup Integration
Required modules: signup, Übercart, workflow_ng
This defines two custom PHP conditions and one custom PHP action and is activated when an Übercart product purchase is complete.
Condition 1: Node has signups enabled
Condition 2: User is not signed up
Action: Sign user up
A word of caution: this does allow a user to purchase more than one ticket but signs the user up only once (as the signup module currently only allows one signup per user). ALSO: this does NOT hide the signup form: that must be done separately by invoking signup module's hook_signup_suppress(). See the end of this post for instructions.
Workflow_ng Configuration
Import this code into workflow_ng's import wizard at /admin/workflow-ng/configurations/0/import
array (
'cfg_2' =>
array (
'#active' => 1,
'#module' => 'workflow-ng',
'#weight' => '0',
'#type' => 'configuration',
'#altered' => false,
'#id' => 1,
'#event' => 'checkout_complete',
'#label' => 'Product purchase signup',
0 =>
array (
'#name' => 'workflow_ng_condition_custom_php',
'#id' => 2,
'#type' => 'condition',
'#label' => 'Node has signups enabled',
'#settings' =>
array (
'php' => '$ordernid = $order->products;
$ordernid = $ordernid[0];
$ordernid = $ordernid->nid;
$node = node_load($ordernid);
if ($node->signup == 1) {
return TRUE;
}
else{
return FALSE;
}',
'used_arguments' =>
array (
),
'used_php_arguments' =>
array (
0 => 'order',
),
),
),
1 =>
array (
'#type' => 'action',
'#label' => 'Sign user up!',
'#name' => 'workflow_ng_action_custom_php',
'#id' => 5,
'#settings' =>
array (
'php' => '$ordernid = $order->products;
$ordernid = $ordernid[0];
$ordernid = $ordernid->nid;
$edit[\'nid\'] = $ordernid;
$edit[\'uid\'] = $order->uid;
$edit[\'signup_form_data\'][\'TransactionID\'] = $order->order_id;
signup_sign_up_user($edit);',
'used_arguments' =>
array (
),
'used_php_arguments' =>
array (
0 => 'order',
),
),
),
2 =>
array (
'#id' => 4,
'#type' => 'condition',
'#name' => 'workflow_ng_condition_custom_php',
'#label' => 'User is signed up',
'#negate' => 1,
'#settings' =>
array (
'php' => '$ordernid = $order->products;
$ordernid = $ordernid[0];
$ordernid = $ordernid->nid;
$query = db_query("SELECT sl.uid, u.name FROM {signup_log} sl INNER JOIN {users} u ON sl.uid = u.uid WHERE sl.uid = %d AND sl.nid = %d", $order->uid, $ordernid);
if (db_num_rows($query)>0) {
return TRUE;
}
else {
return FALSE;
}',
'used_arguments' =>
array (
),
'used_php_arguments' =>
array (
0 => 'order',
),
),
),
'#name' => 'cfg_2',
),
)Signup Form Suppression
Suppressing the signup form can be done by creating a small custom module as follows:
1. Create a folder called "my_tweaks"
2. Create a file called "my_tweaks.info" inside the folder created in step 1
3. Paste this code into it:
name = My Tweaks
description = Suppress signup form for product nodes in order to allow product signups via workflow_ng.
dependencies = signup uc_product4. Create a file called "my_tweaks.module" inside the folder created in step 1
5. Paste this code into it including the opening but not the closing PHP tag:
<?php
my_tweaks_signup_suppress($node) {
if($node->type == 'product'){
return TRUE;
}
}
?>6. Enable the module at /admin/build/modules
Now all nodes of the product type will have the signup form suppressed but will sign users up upon completion of the node sale (at the point in which the payment gateway verifies payment or a store admin sets an order's status to complete).

Im using the 5.x-2.4 version
Im using the 5.x-2.4 version of signup and this doesn't seem to be working. The workflow settings seemed to import okay. No messages pertaining to this in the error log either. Signup is enabled on product node type. Just simply checked out and it didn't work. Regular event registration (manual) works fine.
Any ideas?
seems to work with signup-5.x-2.5
Now seems to work...
Needed to enable sign-up on event (which is what I wanted it for) via admin/content/types/event
This snippet does need work
This snippet only works with the first node in the cart and if the user is logged in. I'll update it soon...
SORRY!
Signup form suppression possible fix
The Signup form suppression module returned an error that broke the site until I added "function" at the beginning of line 2. I don't know if that would be the case for anyone else, but it worked for me. Otherwise this works great, and really helped me out on a project I'm doing for a non-profit.
<?php
function my_tweaks_signup_suppress($node) {
if($node->type == 'product') {
return TRUE;
}
}
NOTE: I have zero PHP skills. I found the solution on the Ubercart site here: http://www.ubercart.org/contrib/5306#comment-25119
The linked page may also be helpful to anyone looking for a similar solution.
Drupal6 version?
is there a Drupal 6 version using rules?
For some reason I'm getting
For some reason I'm getting "import failed".
I added a conditional
I added a conditional statement to the tweak module. I'm using the event module with the uc_paid event module. Initially when I used the code below
<?phpfunction my_signup_tweak_signup_suppress($node) {
if($node->type == 'product') {
return TRUE;
}
if($node->type == 'event') {
return TRUE;
}
if($node->type == 'volunteer_timeslots') {
return TRUE;
}
}
?>
it suppressed signup, which is fine if it's a paid event but if it's not a paid event, there is won't be a "Add to cart" button so there is no way to sign up such event since signup is suppressed. I'm new to php and I'm not sure if this is the best solution but I changed it to this and it seems to work.
<?php
function my_signup_tweak_signup_suppress($node) {
if($node->type == 'product') {
return TRUE;
}
if($node->type == 'event' && $node->sell_price>0) {
return TRUE;
}
if($node->type == 'volunteer_timeslots' && $node->sell_price>0) {
return TRUE;
}
}
?>