5

I have tried making this a rule as well as used hook_user with no luck. It definitely gets inside of the login case (had a watchdog log), but the redirect doesn't happen and they are still sent to /user upon logging in.

I am trying this with no luck:

/**
 * Implementation of hook_user()
 */

function multistep_registration_user($op, &$edit, &$account, $category = NULL) {
    switch ($op) {
        case 'insert':
            multistep_registration_save_content_profile_name($account);
            break;
        case 'login':
            if (!multistep_registration_is_complete($account->uid)) {
                drupal_goto('user/register/complete-registration');
                exit;
            }
            break;
        default:
            break;
    }
}


function multistep_registration_is_complete($uid) {     
    if ($uid == 1) {
        return TRUE;
    }

    $node = content_profile_load('profile', $uid);

    if ($node->field_completed_registration[0]['value'] == 'yes') {
        return TRUE;    
    }

    return FALSE;
}

Why is it not redirecting? New users all have the value set as 'no'.

  • is multistep_registration_user being called successfully? – MikeNGarrett Mar 2 '11 at 21:16
  • The exit is superfluous, it's called in drupal_goto. Have you double checked the output of content_profile_load (with dpm for example) and multistep_registration_is_complete to make sure that they are returning what you expect to see? – Jason Smith Mar 2 '11 at 21:16
  • Yes, it hits that case, I had a watchdog() in there within the if statement. – Kevin Mar 2 '11 at 21:31
8

You could try using LoginToboggan, which allows you to set a redirect on login.

  • That doesn't provide a conditional redirect based on profile completion. There is however a rule available provided by content profile that does a redirect upon login. Check it out. – Jason Smith Mar 2 '11 at 21:21
  • Yes, it allows for redirect on registration/confirmation, but not for a regular login. Trying to funnel folks through to filling out their profile so its not empty. – Kevin Mar 2 '11 at 21:28
  • When I go to the Rule, it says Unavailable argument: Content. – Kevin Mar 2 '11 at 21:35
6

One method that we use is using Rules. It allows you to make a rule for:

  • User has just logged in.
  • User has not completed Content Profile (you can select the particular content type).
  • Do an action for: Redirect user to URL that you want

Hope it helps!

EDIT: You can also make it when a user views a page and has a role you want, redirect them. That way, it forces them to fill it out and doesn't allow them to do anything else (if you want that).

  • I never thought of creating a rule to do that. Would you have to use a contributed Profile module though? – PendragonDev Mar 6 '11 at 0:18
  • The only contributed module would be the Content Profile module... which is what he's using with content_profile_load. That module implements rules hooks to allow you to do this... – mikesir87 Mar 8 '11 at 3:26
  • i tried following tutorials online about rules and redirect but it does not work how come? – jan Jul 19 '11 at 16:06
4

I use Login Destination to redirect after logins on my sites; I know that it has the ability to use php snippets to create conditions for specific situations, but I've never used them.

1

I'll just put this here in answer form, You can use rules to do this, even if the rule provided by content profile isn't available.

Just use the "User has logged in" trigger, add conditions for the fields of interest being empty and redirect.

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.