Pergunta

In Drupal 7, I am using Profile2 (7.x-1.0-beta1) module to add custom fields like 'Author Name' etc to an user's profile page. How do I pull those custom fields in a view (7.x-3.x-dev)? All other custom CCK fields shows up in a view's selection list but not those added to an user profile page.

Foi útil?

Solução

I fail to understand why anyone would use Profile2 (or Content profile) when users in Drupal 7 are fieldable.

From what I understand from the Profile 2 project page, it utilizes Entity API; you may need to use EntityFieldQuery Views Backend.

Outras dicas

<?php

global $user;

$uid = user_load($user->uid);
$profile = profile2_load_by_user($uid, 'showmember_profile');

//laod specific fields from the profile2 showmember
echo $profile->field_firstname['und'][0]['value'];
echo $profile->field_lastname['und'][0]['value'];
echo $profile->field_cityname['und'][0]['value'];
echo $profile->field_phone['und'][0]['value'];

?>

Check for user permissions for the particular role that the user belongs to. check if that role has permissions to view the profile of itself and any other user. To check that go to People >> Permissions section.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a drupal.stackexchange
scroll top