It should work according to the docs (though I haven't tested it), but try replacing line 15 with this and taking out line 16:
$id = $rgrs[0] ->get('document');
It will be faster anyway, since you don't really need the resource, just its ID.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
Just to finish this off (and I realise it's probably not the correct forum). In the final part of this redirect exercise I encountered the problem that others before me have experienced, namely when the postHook fires the logged in user won't yet be reflected in $modx->user->get('id'), so basing a resource redirect on this call doesn't work (actually redirects on logout).
Instead, by using the loginResourceId to redirect to an interim 'redirect resource' where the identify & redirect snippet lives, it works correctly. Hoorah!
However, that uses unneccessary cycles and is really a bit clumsy. There's a more elegant and tighter solution out there somewhere (I tried using $hook->getValue('id'); but it failed), and if anyone knows it please let me know.
Once I get the code cleaned up I'll post the whole problem/solution for reference.
David Heriot
pfsmedia