I've set up a custom login page witht the difference that that one should redirect the user to another page.

I use the default drupal login form so I dont really now how to fix the form alter for my custom form without it to change the default login form too.

What could I do to fix this?

My code:

function mymodule_cv_login() {
    // Print the user login form
    $form = drupal_get_form('user_login');

    $form['redirect'] = 'cv';

    return $form;

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'user_login') {
        $path = 'profil';
        $form['#action'] = url($_GET['q'], array('query' => array('destination' => $path)));

2 Answers 2


You can check what page you are on by looking at $_GET['q'] (or using the arg() function) so you could base your alter on that.


There is always the Login Destination module http://drupal.org/project/login_destination which I will probably handle the cases you want to cover as well.

  • I used rules before, but each login page has to have a different look. Thats why I wanted a seperate login. Commented Jan 29, 2012 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.