Question

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'.

Was it helpful?

Solution

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

OTHER TIPS

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 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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top