Redirect to a content page after login only from that page On one certain page of my site, users have to log in before going any further. They don't have to be logged in to see most of the rest of the site content, but on this one specific page, they do have to be logged in. I figured out how to put a barrier up that forces users to log in before seeing that page's content (i.e., if users aren't logged in, the only thing on the entire page is a line that says "To create content, you must first log in" and there's a link to the login page), but how do I redirect newly logged-in users directly back to that same page (which now will have content on it) so they can now see its content? 

At the moment, after they log in, it just takes them to their profile page.

In other words, if users log in on any other page, it's fine if they're redirected to their profile page, but on this one specific page, they need to stay put. I've seen lots of variation of the following code:

function hook_user_login(&amp;$edit, $account) {
drupal_goto('node/1');
}


But I don't think this is what I'm trying to accomplish. The current code I have in there looks like this:

$sample1 = '&lt;a href="../user"&gt;log in&lt;/a&gt;.';
$sample2 = 'To create a classified ad, you must' . " " . $sample1;

global $user;
if ($user-&gt;uid == false){
return $sample2;

}


I've seen some code like this that looks promising:

#action' =&gt; url($_GET['q'], array('query' =&gt; drupal_get_destination()))


But I can't figure out how to make it work. Anyone got any ideas?
Hope this will give you, 

In Drupal 7, you can achieve it by using destination parameter.

Just add the destination parameter in the URL where you want to redirect it.

For example if you are in login page and after login if he want to redirect to some node say about page then

YOUR_DOMAIN/user/login?destination=about


Just add the destination parameter in "To create content, you must first log in" link. On click of this link it will redirect to User login page with the destination parameter. After login it will redirect to the path you have specified in the destination value.