Last updated February 23, 2013. Created by entrigan on February 26, 2011.
Edited by echoz, brayo4, wmostrey, David Vespoli. Log in to edit this page.

Getting Started with Profile2

  • Creating and Managing Profile Types - To get started with profile2 you will need to create a new profile type or manage the default one. This can be found at admin/structure/profiles
    Profile types found in Admin Structure Menu
  • Creating and Editing your Profile - By default profiles can be created and edited at user/uid/edit. There should be a secondary tab for each profile the user has access to.
  • Private Fields - Private fields are only visible to the profile owner and administrators. Field privacy is managed through the check box at the bottom of field edit page (i.e. /admin/structure/profiles/manage/profile/fields/myfield).
  • Check box at bottom of field edit page

  • Profile Permissions - In order to make profiles creatable and visible to users you will have to manage the permissions for each profile type (located at /admin/people/permissions#module-profile2).

Profile Permissions

Profile Pages

The profile pages module (included with profile2) allows for profiles to be managed outside of the normal user edit page. Instead of a tab on the user edit page, the profile view and edit pages will be located at /profile-profile_machine_name/[user id].

Link to profile page with views

  • Add FIELDS "user uid" (The owner of the profile).Then check option "Exclude from display" in the field configuration window. Remember to put this field before any other field in FIELDS render, so that this token could be available for followed fields.
  • Add another FIELD, e.g. "nickname" and make each user "nickname" linked to associated user profile.When configure this field "nickname", click REWRITE RESULTS and check option "Output this field as a link". Click REPLACEMENT PATTERNS to ensure token [user] is available for this field "nickname". Write profile-profile_machine_name/[user] (e.g. profile-main/[user]) for Link path.
  • Save all configuration. Field "nickname" in views will be linked to each user profile page.

For views integration with multiple profile2 types

Visit this page http://drupal.org/node/1114454. Pay attention to entry # 72 and you should be home free.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Good call for adding instructions on how to use Profile with views! It makes it much easier to understand how best to use this module.

Thanks!
Caryl

Caryl Westerberg
cjwest@acm.org

I have added some extra fields but I cant find them to add in views. What am I missing here?

add a relationship to the view to pull in fields from related entities

freedom isn't free

I have to different roles. "musiker" and "bonus-musiker" with profile2.

My problem is the paths

www.aaa.com/profile-musiker/nid
and
www.aaa.com/profile-bonus-musiker/nid

I would like to have: name instead of nid??

I can not change paths with URL aliases patterns. i would like to have all similar like /...../profile-name/artistname

Any ideas please?

Cheers
Basset

HI,,are there any exported templates I can import into my site,,,to cut down on so much typing and waiting....

Lazy Admin

Hi Sir,

I was following the above instructions for integrating views, but for some reason, the link still outputs user/[user:name] instead of profile-main/[uid].
I am using 7.12.
I don't know where to upload image so I'll just put the link

configure

Users View

Sorry for the bad quality of image but if you zoom in on the first image the link path is set to profile-main/[uid], but after saving and saving again, the view on the users side is still users/[user:name]...

hope to hear from you soon.

I see, the "link to user profile" should be unchecked. if you are using profile2

I got an error "page not found" when creat a view to replace profile-profile_machine_name/[uid] to profile-profile_machine_name/[user]. Please help me correct it.

This doesn't make sense to me. None of the fields that I make for the "Profile Types" that I create are exposed in views. Even the User ID seems to be missing. As such, these instructions don't make sense... Any help would be appreciated.

It sounds to me like you're trying to create a view for user's profiles when instead you selected "Profile Type" when you starting the view (which would relate to showing a view of the different types of profiles you have on your site). Try it with "Profile" instead.

Thanks, I eventually got it figured out. I'm new to Drupal 7 as well, so I didn't understand that I had to add the "Profile" relationship in my view before the profile fields would be exposed. It's all good now :).

I've since figured out why the profile module is useful as well. From what I understand, you can't add new fields to the "user" profile page out-of-the-box. So I've instead created fields using the Profile2 module, and used those fields to customize the User pages using Panels. It still makes more sense to use the User profiles instead of the content-types generated through the Profile2 module since I can't use Pathauto with the Profile2 module. It seems to me that Profile2 is meant to be used in conjunction with the default User module.

I don't understand the purpose of creating a profile view when you have the main user profile page to begin with...Unless you would only be using views with this for certain things.

------------------------------
http://www.muttr.com

I've finally been able to get a handle on Profile2 and Profile Pages (or so I thought), and have set up a view per the instructions. The problem is that my link to profile-main/[uid], which reveals itself correctly on roll-over, always reverts back to user/[uid] on click. So I always end up at the user account view instead of the profile view. Any ideas on what I'm forgetting here? Thanks......

How can I access these Profile 2 fields programatically? I am trying to save a new user, and in that save I want to save their other profile values. See code here:

<?php
ini_set
('display_errors',1);
error_reporting(E_ALL);
/**
* Implements hook_menu()
*/
function zoho_create_user_menu() {
 
//drupal_set_message("Hello!");
 
$items['zohocreate'] = array(
   
'title' => t('Create a user from the Zoho CRM'),
   
'page callback' => 'zoho_create_user_create_zohocrm_user',
   
'access arguments' => array('access content'),
   
'type' => MENU_CALLBACK,
  );
  return
$items;
}
function
zoho_create_user_create_zohocrm_user() {
 
//Get the data from the posting page and put it in an array
 
$data = $_GET;
 
//drupal_set_message($data['email']);
// print("<pre>".print_r($_GET,TRUE)."</pre>");
  // Check to see if the auth key matches
/*
if($data['auth'] != "asdKsefk44534AKS3k4ksdk4sadf2353SDFVL") {
          header("Location: http://www.example.com/"); // Redirect browser since auth code is wrong
        exit; } */ 
  // Create the new username from First initial, last name and account id
  
$username = $data['fname']{0}.$data['lname'].$data['id'] ;
 
// Put values into the array for creating the user
 
$new_user = array(
     
'name' => $username,
     
'pass' => user_password(),
     
'mail' => $data['email'],
     
'init' => $data['email'],
     
'field_fname' => array(LANGUAGE_NONE => array('value' => $data['fname'])),
     
'field_lname' => array(LANGUAGE_NONE => array('value' => $data['lname'])),
     
'status' => 1,
     
'access' => REQUEST_TIME,
);
// $account returns user object
$new_user['roles'][DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
$account = user_save(null, $new_user);
// Send new user no approval required email
_user_mail_notify('register_no_approval_required', $account); 
}
 
// if you return a string, it'll be shown in the page body area.
 
return("SUCCESS");
?>

But I know that the way I'm trying to save fname and lname right now doesn't work. Please help.

I added this code after what I have above to make the user profile fields save. Can I make this shorter?

<?php
//Set custom fields for user
  //$account = user_load($uid); // Loading account
   
$edit = array(
     
'field_zohoid' => array(
       
'und' => array(
         
0 => array(
           
'value' => $_GET['id'] ),
        ),
      ),
    );
   
user_save($account, $edit);
   
$edit = array(
     
'field_first_name' => array(
       
'und' => array(
         
0 => array(
           
'value' => $_GET['fname'] ),
        ),
      ),
    );
   
user_save($account, $edit);
   
$edit = array(
     
'field_last_name' => array(
       
'und' => array(
         
0 => array(
           
'value' => $_GET['lname'] ),
        ),
      ),
    );
   
user_save($account, $edit);
}
?>

This is what I used to fetch the profile field values

global $user;
$profile_values = profile2_load_by_user($user->uid);
$blogger_profile = $profile_values['blogger_profile'];
print $blogger_profile->field_full_name['und'][0]['safe_value'];

Were you looking for this?

I have done the below steps (works well! used hook_alter_form to hide the non-appropriate profile type: http://drupal.stackexchange.com/questions/5661/change-the-e-mail-value-d...)

However, I need to now override the default user registration form *processing* and
programmatically assign the profile type depending whether the user has signed up using the vendor or the customer url.

Any help much appreciated,

gvanto

------------------------------------------------------------------------------------------------------------------

I have set up 2 profile types:

- Vendor
- Customer

I would like to create a vendor-specific user registration at
mysite.com/register-vendor

(And for customer, to sign up at /register-customer )

The two diff registration forms should have different input data.

I've checked the "Show on user registration" for each of the two types of profiles (during creation).

On the registration form, a form is shown for both profile types Vendor and Customer ...

Not sure it's best way to do it but I guess I could try and hide the Customer fields during Vendor signup (if the current url == /register-vendor ) but not quite sure how to hide fields on registration based on URL? (Or even if there exists a more elegant solution such as a option in admin I've not considered?)

Any help much appreciated,

Regards,
gvanto

Any help

found this, fantastic: http://grasmash.com/article/managing-account-registration-multiple-user-...

Thanks for a brilliant module: Profile2 !

Gvanto

I've created 2 profile types: Vendor and Consumer:

While Vendor profile view works at: /profile-vendor/8
(= profile-[machine-name-profile/[user_id] )

The same does not work for profile-consumer :-(

http://bit.ly/JObb9j
(login: consumer1 / joker45 )

I've created 2 profile types: Vendor and Consumer:

While Vendor profile view works at: /profile-vendor/8
(= profile-[machine-name-profile/[user_id] )

The same does not work for profile-consumer :-(

http://bit.ly/JObb9j
It says page not found ... I've checked this user's uid=7

found issue (had machine name still on old value - it didn't change automatically when I updated the Profile name!)

Not sure what I am doing wrong here, but so far I have everything working great using Profile 2 module, but now when I login to 1 test profile I am able to add/edit another type. I have 2 profiles - Nonprofits and Consultants. When I login to the nonprofit profile I get My Consultant as an option to add to that profile. What did I miss?

Are you sure you have given the right permissions to add/edit profiles for both the Roles of the users?

As I understood, there is a possibility to use links to taxonomy terms in Profile2 profiles. Yes, I can add a field that links profile to taxonomy term, I can display it in user's profile but that's all! It doesn't work as a taxonomy - I mean no users are being shown when I click it. Am I doing something wrong or Profile2 really doesn't work with taxonomy (the same problem as whith native Drupal user profiles)?