Create path alias programatically when node is created I have a custom content type that is created by a module.  Is there a hook I can use to set the path alias of my custom content type when a node is created?

One of my fields is an alpha-numeric code, and I want to use that in the path. eg.: 'event/myc0d3'

I noticed that this function (path_set_alias) existed in 6, but I can't find the equivalent for 7.  And do not know where I would call it.
Instead of using hook, Pathauto module should be used where you can define specific pattern how aliases are generated per content type (at /admin/config/search/path/patterns). In there you can use replacement patterns or code your own. It's much cleaner approach.

Otherwise you can try hook_node_presave($node) and change the alias directly:

$node-&gt;path['pathauto'] = 0; // Required only if Pathauto is enabled.
$node-&gt;path['alias'] = "foo/bar";


or use the path_save(&amp;$path) function directly as below:

$path = array('source' =&gt; "node/$node-&gt;nid", 'alias' =&gt; 'foo/bar');
path_save($path);