I am struggling with this for a while. In my setup, every user gets to have the main profile. However if there are all fields empty, the profile is not created. Problem: It is not possible to access fields in user profile, for example using rules or php. Rules gives error - The variable or parameter is empty.

After editing any of profile fields, the profile is created and available for extracting data. So is this any sort of bug or is it somehow possible to save/enable even empty profile, to be able to work with fields?

Thank you

  • are you using profile2 module? This can be altered via the user HOOKs. Aug 8, 2014 at 17:53
  • @AneekMukhopadhyay hi, yes I use profile2 module. So how to be able to "activate" profile, to be able to get to/or add values to empty profile? Thank you.
    – loparr
    Aug 8, 2014 at 17:55

1 Answer 1


A quick fix is to use a bit of custom code to save the profile fields in the time of user creation as empty. Say you have a profile of type of "main". This have to be done while creating the users, find the appropriate hooks here.

Now just create the user's profile with empty values.

// create profile object
  $profile = profile_create(array('user' => $account, 'type' => 'main'));
  // populate profile fields
  $profile->field_firstname[LANGUAGE_NONE][0]['value'] = '';
  $profile->field_lastname[LANGUAGE_NONE][0]['value'] = '';
  $profile->field_gender[LANGUAGE_NONE][0]['value'] = '';
  // save profile

Ref: here and here

This may solve your problem. if now then let me know.

  • Hi, my workaround was to create profile using rules when new account is created, but it does not seem to work. Do you think it would be possible to add this custom code to rules with event - after saving a new user account? Thank you for help.
    – loparr
    Aug 8, 2014 at 18:16

Your Answer

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

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