2

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

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.

|improve this answer|||||
1

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.

|improve this answer|||||
  • I used rules before, but each login page has to have a different look. Thats why I wanted a seperate login. – Daniel Holm Jan 29 '12 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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