Run module after 'Order status gets updated' Action runs I need to load the order object and run the init function when the order status is updated in Ubercart instead of using hook_menu(). How do I hook into the "Order status gets updated" action?  The order state should be "Payment Received."

Does it have something to do with the following code:

function uc_order_rules_event_info() {
  $events['uc_order_status_update'] = array(
    'label' =&gt; t('Order status gets updated'),
    'group' =&gt; t('Order'),
    'variables' =&gt; array(
        'order' =&gt; array(
            'type' =&gt; 'uc_order',
            'label' =&gt; t('Original order'),
        ),
        'updated_order' =&gt; array(
            'type' =&gt; 'uc_order',
            'label' =&gt; t('Updated order'),
        ),
    ),
);


function hemo_menu() {
  $items['add_listing'] = array(
    'page callback' =&gt; 'init',
  );

  return $items;
}

function init() {
  foreach ($order-&gt;products as $product) {
    $array = data_array($product-&gt;data['attributes']);

    foreach ($array as $property =&gt; $value) {
      $product-&gt;$property = $value;
    }

    $product-&gt;primary_email = $order-&gt;primary_email;
    create_directory_listing($product);
  }
}

function data_array($arr) {
  $array = array();

  foreach ($arr as $key =&gt; $value) {
    foreach ($value as $key2 =&gt; $value2) {
      $chars = array(" ", ",", "'", "(", ")", "__");
      $key = str_replace($chars, "_", strtolower($key));
      $value2 = ucwords($value2);
      $array += array("$key" =&gt; $value2);
    }
  }
  return $array;
}

function create_directory_listing($product) {
  $node = new stdClass();
  $node-&gt;type = 'directory_listing';
  node_object_prepare($node);
  $node-&gt;language = LANGUAGE_NONE;
  $node-&gt;uid = $product-&gt;order_uid;
  $node-&gt;field_order_product_id[$node-&gt;language][0]['value'] = $product-&gt;order_product_id;
  $node-&gt;field_order_id[$node-&gt;language][0]['value'] = $product-&gt;order_id;

  if (isset($product-&gt;attendee_name)) {
    $node-&gt;title = $product-&gt;attendee_name;
  }
  if (isset($product-&gt;institution)) {
    $node-&gt;field_institution[$node-&gt;language][0]['value'] = $product-&gt;institution;
  }
  if (isset($product-&gt;lab_group)) {
    $node-&gt;field_lab_group[$node-&gt;language][0]['value'] = $product-&gt;lab_group;
  }
  if (isset($product-&gt;address)) {
    $node-&gt;field_address1[$node-&gt;language][0]['value'] = $product-&gt;address;
  }
  if (isset($product-&gt;address2)) {
    $node-&gt;field_address2[$node-&gt;language][0]['value'] = $product-&gt;address2;
  }
  if (isset($product-&gt;city)) {
    $node-&gt;city[$node-&gt;language][0]['value'] = $product-&gt;city;
  }
  if (isset($product-&gt;state_or_region)) {
    $node-&gt;field_zone[$node-&gt;language][0]['value'] = $product-&gt;state_or_region;
  }
  if (isset($product-&gt;country)) {
    $node-&gt;field_country[$node-&gt;language][0]['value'] = $product-&gt;country;
  }
  if (isset($product-&gt;phone)) {
    $node-&gt;field_phone[$node-&gt;language][0]['value'] = $product-&gt;phone;
  }
  if (isset($product-&gt;primary_email)) {
    $node-&gt;field_email[$node-&gt;language][0]['value'] = $product-&gt;primary_email;
  }
  if (isset($product-&gt;zip_or_postal_code)) {
    $node-&gt;field_postal[$node-&gt;language][0]['value'] = $product-&gt;zip_or_postal_code;
  }
}
I believe you're looking for hook_uc_order() which runs for several operations, including the update operation which is:


  Called when an order's status is changed.


Assuming your module is called "hemo" you code might look something like this:

function hemo_uc_order($op, $order, $arg2) {
  if ($op == 'update') {
    if ($order-&gt;order_status == 'payment_received') {
      // Do something with the $order object.
    }
  }
}


Remember to clear Drupal's cache once you've implemented the new hook or it might not get registered.