1

Step One

I am wondering the best approach to add custom fields to the profile2 module. I saw how to get data from a custom field How do I reference (what is the syntax I have to use) to get the data of my Profile2 custom fields?. But I am not sure how to add the fields. What hook do i need to use. I cannot find a particular page for using the profile2 module. Could someone post a code snippet. I have used the form API so I have knowledge of constructing particular entities which I think is what fields are called in Drupal 7. I just though I could use the text field and integer fields that already exists and then insert these fields into the eCommerce table.

I can retrieve the field for firstname

function test_first_name()
   {


$uid =3;

   // calls the user_load functions
   $account = user_load($uid); 
   // now pass the account the variable to the function profile2_load_by_user
   $profile = profile2_load_by_user($account);
   //var_dump( $profile); // drupal_render(field_view_field('profile2', 
   $print_first_name =  drupal_render(field_view_field('profile2',  
   $profile['main_profile'], 'field_first_name'));
   print $print_first_name;



}

I have just added the product_name into my members profile as well as a product_price .I want to update the ecommerce module with the relevent fields. Does anyone know a way to insert relevent fields into the commerce tables.

I discovered the API for profile2 http://drupalcontrib.org/api/drupal/contributions!profile2!profile2.api.php/7

 function mymodule_form_profile2_form_alter($form)
 {
 }

I am wondering if i can just use the Subscriptions and recurring payments an integrate it into profile2.

  • You can use hook_form_alter ! – niksmac Apr 19 '12 at 12:00
  • I'm using the admin/structure/profiles page to add fields but I'm unsure if that's what your looking for. – FLY Apr 19 '12 at 14:12
  • My plan was to add fields to the commerce table and I wasn't sure how to do that. I then though why not add a standard text field and other basic data field types and update the commerce table which is relevant to adding a product. – Alexander Apr 19 '12 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.