Im trying this too on my site under the folder forum.
If you can see here on bbpress the code works that way in my case
So my guess is that you can create a custom php for example http://www.mysite.com/logout which will redirect on a file like wp-login.php which will fetch the id from the user and then will do the redirect to the page you want.
its really simple to achieve this type of thing , use a plugin like this
the plugin basically uses some code already in WordPress that you can use.