How to set a custom URL for a node without pathauto?
This seems to be a duplicate of this issue

Try using hook_node_insert($node) for new content and/or hook_node_update($node) for existing content:

function mymodule_node_insert($node) {
  if ($node-&gt;type == 'mytype') {
    $node-&gt;path['alias'] = _some_awesome_pattern_maker($node);
  }
}

function mymodule_node_update($node) {
  if ($node-&gt;type == 'mytype') {
    $node-&gt;path['alias'] = _some_awesome_pattern_maker($node);
  }
}

_some_awesome_pattern_maker($node) {
  // massage node and return string
}