Using custom_url_rewrite_inbound()
for this would be somewhat similar to using a sledgehammer to adjust the angle of a crooked picture - can be done, but it is cumbersome and comes with the risk of causing some damage ;)
A better solution depends on what you want to achieve exactly, and how often (i.e. for how many nodes) you need to do it, so you should explain your scenario a bit more detailed. Some possible approaches include:
- 'Enrich' your nodes with data/fields for both versions, and adjust the actual output depending on user role
- If you use CCK, you could use the fields permission settings for this.
- You might also do some adjustments in the theme layer via custom node templates.
- Another approach would be via
hook_nodeapi()
(operation 'view') from a custom module, removing entries from the content array depending on user role.
- Provide explicit redirection to other nodes depending on user role (your explicit question)
- replace the standard node page callback via
hook_menu_alter()
with a custom one. Within that, you check the role. If it is ok, you just call the standard callback, else you issue a drupal_goto()
(based on some general logic, if possible).
- If the 'special' cases are rare, you could do this via
hook_nodeapi()
as well, again reacting to operation 'view', but you'd need to make sure that you only do this for node page views, not if the node is just displayed as a teaser along with others.
- Implement
hook_init()
in a custom module, check the path (arg()
or $_GET['q']
) and the role, issue drupal_goto()
as needed. (Beware of cached pages - if you need to cover those, use hook_boot()
instead).
Etc. ... - I'm sure there are more options, so you might want to provide more details on your problem/goal/scenario to allow for a more precise suggestion.