Hi,
how can I redirect to the usernode upon creation of a user?
(i.e user is created by admin, so redirection is necessary for editing details)

CommentFileSizeAuthor
#4 105033.patch770 bytesyhager

Comments

fago’s picture

Status: Active » Fixed

you can write a simple module which uses hook_user to detect new users and makes the redirect

mtk’s picture

thanks, this is what I did:

<?php
function mymodule_user($op, &$edit, &$account) {
  if ($op == 'insert' && user_access('administer users')) {
    // we don't use drupal_goto() directly, because this will
    // abort some actions (e.g. sending notification email).
    $nid = usernode_get_node_id($account);
    $_REQUEST['destination'] = "node/$nid";
  }
}
?>
Anonymous’s picture

Status: Fixed » Closed (fixed)
yhager’s picture

Version: master » 5.x-1.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new770 bytes

The above seemed to have been working correctly for the 4.7 version of the module, but for the 5.x version it does not.

I had to apply the attached patch to make it work, otherwise, the value returned from usernode_get_node_id() would have been zero.

fago’s picture

Status: Needs review » Fixed

hm, I don't see why this patch should be needed as usernode is the only module which should set node_id. So if you need this, there must be another bug which causes this.

Anyway, to the topic of this issue. Now you can also create the redirect with workflow-ng.

yhager’s picture

Only from looking at the code, this is possible. node_id might be assigned FALSE, if there is no entry in the table yet (db_result() returns FALSE). However, I am not sure what flow would cause this, but this is what happened in my case.

Thanks for the pointer for workflow-ng, this module looks great! I certainly could use it in various other cases other than this one :)

Anonymous’s picture

Status: Fixed » Closed (fixed)