Redirect after login to specific page We have a link on our site which will redirect users to the edit profile page when they are logged in.

We have same link for the anonymous users which will redirect the user to login page when it clicked. 

We would like to redirect users to the edit profile page after login but if users use normal login link, after login, they are redirected to the homepage.

I would like to know how we can redirect users to edit profile page after login only if they clicked on the edit profile link.
In Edit Profile link append destination parameter like: 

if(user_is_anonymous()){    
  $editlink = l(t('Edit Profile'), 'user/login', array('query' =&gt; array('destination' =&gt; 'user/UID/edit')));
}


Then after login, it will redirect to profile edit page.