Hi,

I have two profiles roles at my website(Producers and Fans) and it have their own fields, eg.

Producers:

Name
Bio
Songs
Url

Fans:
Name
About me
Music Styles
Url

So, in the configuration page of the PCP module appear all this fields like:

Name
Bio
Songs
Url
Name
About me
Music Styles
Url

I check all of them but when a Producer or a Fan access they own profiles the tip shows one of all this fields and if the field owner have a different role the page display access denied when he try to access to fill the field.

I want to display the producers field only for producers and the fans field for fans.

Sorry about my english.

Thanks for help me.

CommentFileSizeAuthor
#5 pcp-support_Profile_role-852846-5.patch711 bytesFooZee

Comments

BarisW’s picture

Status: Active » Postponed (maintainer needs more info)

Hi Lesley,

this sounds like something I can fix. However: how do you manage to get role-specific profile fields? Are you using a module for it? If so: which one?

lesleyfernandes’s picture

BarisW’s picture

Assigned: Unassigned » BarisW
Status: Postponed (maintainer needs more info) » Active

Ok, thanks. I'll have a look in the next couple of days

marty.true’s picture

Any word on this issue? I am having the same exact dilemma...
If I have a profile field in category "A" marked as include in PCP but it is in a profile category that only a certain role has, it still shows to all users as a field to be completed.

I too am using Profile Role...

Thanks for looking into this!

FooZee’s picture

Status: Active » Needs review
StatusFileSize
new711 bytes

Ok

Now I've been waiting for a while, but no one came up with a solution, and my client started asking for this function strongly, so I had to dig in the code myself and her we go, I found a solution (that worked for me) and I'm NOT very experienced in Drupal module development, so please correct me I'm wrong :)

This patch, makes the block only show fields corresponding to the role which the current user belongs to :) (the patch is against 6.x-2.1 stable release)

BarisW’s picture

Status: Needs review » Patch (to be ported)

Thanks Mahmoud,

the patch is working great! Apologies for not fixing it earlier, all of my spare time went into the www.drupal7releaseparty.org website.

I've changed it a little bit to confirm to the Drupal coding standards.
And I used a variable $profile_role_used so we don't have to do the module_exist check on every field.

function pcp_get_tagged_profile_fields($fid = 0) {
  $where = '';
  $args = '';
  $profile_role_used = module_exists('profile_role');
  
  if ($fid > 0) {
    $where = " WHERE fid = %d";
    $args = array($fid);
  }
  $query = db_query("SELECT * FROM {profile_pcp} LEFT JOIN {profile_fields} USING(fid) $where", $args);
  $fields = array();
  while ($result = db_fetch_array($query)) {
    if ($profile_role_used) {	
    	global $user;
    	if (profile_role_access_category($user, $result['category'])) {
    	  $fields[] = $result;
    	}
    }
    else {
      $fields[] = $result;
    }
  }
  
  return $fields;
}

I'll add it to the next release. Great work!

BarisW’s picture

Status: Patch (to be ported) » Fixed

Added to 6.x-2.2

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.