You are here

function domain_rules_action_set_node_domain in Domain Rules 7

Custom hook Do on action 'set node domain'

Parameters

string $subdomain:

node $node:

File

./domain_rules.module, line 172
domain_rules.module @description Port of 'Domain rules' by shushu for Drupal7

Code

function domain_rules_action_set_node_domain($subdomain, $node) {
  $domain = domain_lookup(NULL, $subdomain, TRUE);
  if (isset($domain['domain_id'])) {
    $domain_id = $domain['domain_id'];

    // Based on #893450 - use -1 in case of 0
    if ($domain_id == 0) {
      $domain_id = -1;
    }
    $node->domains[$domain_id] = $domain_id;
  }
  else {
    drupal_set_message(t('The domain %domain does not exist.', array(
      '%domain' => $subdomain,
    )), 'error');
  }
  return array(
    'node' => $node,
  );
}