Redirecting from login to a specific web page for CiviCRM

Have you ever wanted to redirect website users when they login to a specific page?

Maybe you want to show different rates for logged-in members for an event or service or you may have sent an email to members and you want them to visit a specific form.

In Drupal this can be easily done using a destination parameter:

"www.myorganisation.com/user/login?destination=node/1"

To find out the node number of the page you are directing users to, simply edit the page and the node will show up in the URL bar.

You can also redirect to CiviCRM pages with a bit of extra work. CiviCRM adds other parameters into the url, so we need to rewrite those parameters as HTML so that they can be followed. So if you want to redirect to a contribution page, the ? needs to be rewritten as %3F and the & as %26

So, what would normally be: "www.myorganisation.comcivicrm/contribute/transact?reset=1&id=3 would become www.myorganisation.com/civicrm/contribute/transact%3Freset=1%26id=3"

So the full destination rewrite would be:

www.myorganisation.com/user/login?destination=civicrm/contribute/transact%3Freset=1%26id=3

Easy!

You can see the full list of HTML url encoding references on the W3 website.