[eluser]Majd Taby[/eluser]
i had this functionality built into CodeExtinguisher. It was called 'extra_uri_segments' and they would be carried around the system until they were replaced. However, I deprecated that when query_strings were introduced since query_strings are a more robust solution. But to answer your question. I would add the primary key to userdata. So something like this:
Of course, this code isn't that good (you can factor out the common code and combine the conditions..but it should give you and idea.
But to answer your question. Don't forget that all the links that codex uses are set in codexcontroller:etConfig() so if you want to modify them so that they always maintain the extra uri segments, it's very easy to do so. Here's what you would have to do:
1) Add $this->extra_uri_segment = implode('/',$this->uri->uri_to_assoc(3)); in codexcontroller:etConfig()
2) Append .'/'.$this->extra_uri_segments to all the links and form actions in codexcontroller:etConfig