5

I inherited a Drupal (D7) site with existing users. Now I want to add new fields to the user profile, but they will be required.

New users will have to fill out these fields when registering. Existing users will have to fill out these fields when trying to save their profile.

But what I would want is for existing users to be redirected to their profile page after logging in. Of course, I would also like to display a message on that page that they need to complete their profile with this new information.

Is this possible in Drupal?

1

Peter,

there are two modules for such thing:

  1. complete_profile
  2. pfff

But.. I want to try your rules solution because the modules above don't work with hybridauth :(.

If you don't use hybridauth you'd better try complete_profile. It doesn't allow user to go to another pages if required fields are empty.

  • I had solved it with the Rules Module, but a while ago, I switched to the Complete Profile module. It makes it easier (when I changed fields on my user entity, I would have to change my rule). – Peter Oct 9 '14 at 13:09
3

I fixed this with the Rules Module.

First, I set the necessary fields in the user profile as required. That fixes it for new users that want to register.

Then, a little more complex, I used the Rules module for the existing user, with the following setup:

  • Event: user has logged in
  • Actions:
    • page redirect (to user/[account:uid]/edit)
    • show a message on the site (to clarify why the user was sent here)
  • Conditions:
    • One OR group with the following conditions:
    • Data value is empty (with site:current-user:field-lastname)
    • Data value is empty (with site:current-user:field-firstname)
    • etc.

This works perfectly. The only minor point is that when I add a required field, I also have to add a condition to the OR group manually.

1

You can do it of course. But for that you have to create your own module with the hook_user_login. You can also give a look at the documentation that has a simple example to redirect user to his profile page to fill data.

  • Or use Rules Module to implement hook_user_login() – GoodSp33d Aug 20 '12 at 13:32

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.