I have created a new Profile Type with Profile2 module. Now I want to override it, importing three existing fields from my original Account (First Name, Last Name, Email) with their own values (that have already been set in the registration process).

I think I must try copying profile2.tpl.php on my theme page, but no changes seems to happen. Any idea about how to do it?

  • 1
    I am not clear with your requirement. Why do you mention using profile2.tpl.php?..You just want this for a display purpose or you want those fields in the profile you created to actually hold the corresponding values from user registration form? – Neo Oct 8 '13 at 12:48
  • I need to repeat those fields in my new Profile Type, so the user can see and change their values, if they want. – Fernando Suárez Oct 8 '13 at 14:51

Profile2 modules gives profile entity apart from we have in default as user.I am not putting the codes , but here is my idea,

  1. manually add those three fields to the profile you have created.
  2. loop through all users, load their profile, I guess you can use profile2_load_by_user() to load the profile inside the loop
  3. Check if you are getting the added fields in the loaded profile object.
  4. Map the fields on user entity to profile entity.
  5. save the profile using profile2_save() 5.
  6. Delete the fields from user entity, once you ensure mapping is in the way you want.

NOTE: function listed may need a replacement,as I have not tested the workflow.

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.