Redirecting from login to a specific web page for CiviCRM

A photo of Heather Oliver

Heather Oliver

Systems and databases Manager

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 but want them to be logged in first.

In Drupal this can be easily done using a destination parameter user/login?destination=

Here's how it fits into the URL

"www.myorganisation.com/node/1" is a link to this specific page on your site

"www.myorganisation.com/user/login?destination=node/1" will check if someone is logged in before taking them to node/1.

Tip: If you want to know the what page node is simply edit the page and the node will show up in the URL bar.

Redirecting to a CiviCRM page

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"

Then you can add in the log in destination parameter like we did above:

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

Other resources

You can see the full list of HTML URL encoding references here: https://www.w3schools.com/tags/ref_urlencode.asp