As a site developer for a web development agency, I often have the need to send clients pieces of content (pages, blog posts, team bios, etc) for review. These are pieces that cannot yet be live in the site, so they need to remain unpublished until they can be reviewed.
There are a few great modules out there aimed at solving the content review process, but many of them are overly complicated for the majority of, well, less tech-savvy clients. The best of these is the Workbench module, which has accumulated some other contributed modules as well, but again, this setup takes time and training has to be given to the client in order for them to become a part of the process. Many times - at least in our case - clients just don't have the training time to learn or the desire to retain the necessary steps.
My Simple Solution
The solution is actually quite simple. When sending a link to a client, we can simply add a small snippet to the URL ("user?destination=") that forces the client to log in before being redirected to the final piece of unpublished content. (Without even more development, it still makes sense to give the client a user/pass and permission to see unpublished content of a certain type.) Here is how I might format a URL for the client if I want them to see the blog landing page of this site (if it were unpublished):
With this format, the client is sent to the user login page (/user) and then redirected to the blog landing page (/blog) upon successful login. All sounds pretty nifty, right?
The Minor Pitfall (and How I Solved It)
The issue comes when a client user is already logged in. Unfortunately, in this circumstance, Drupal does not redirect the user and instead leaves them sitting on the (extremely useless) user info page (/user). The redirect is only triggered when the user completes the login form, so no log in = no redirect. Wah wah.
So what to do? Write a module of course! To get past this unfortunate road block, I wrote a small module that checks to see if the URL contains the "user?destination=" string. If it does, check to see if the user is logged in. A logged in user gets redirected to the destination in the URL, a non-logged in user proceeds as normal to the user login page.
A Neat Bonus!
To even better facilitate the process, the module also includes a button (in the bottom right corner of the browser window) on any unpublished piece of content in the site. Click the button and you get a link to the page you're on - with "user?destination=" string included - copied to your clipboard for you to send to a client. Couldn't be easier!
I have several ways I would like to improve on the module, but if you have any thoughts, leave a comment here or in the issue queue on github. (Better still, fork the project and issue a pull request!)