Displaying User Attributes in sets on Profile / Edit page

Permalink
Hi guys,

I am currently playing with the User Attributes for registered members and am wondering if anyone can shed light on this for me, I am hoping it is a simple answer but I cannot figure it out with my limited php knowledge.

I am hoping to achieve a very similar result to the concrete5.org Edit Profile page where the form questions are grouped under headings such as 'Personal Information', 'Address' and 'Public Profile'.

My thoughts so far were to add my questions to User Attribute Sets but I cannot figure how to display these sets independently.
I can see the following code on single_pages/profile/edit.php which prints all attributes checked to be editible on profile but am unsure how I can change this to only display a User Attribute Set instead.

<fieldset>
<?php
$af = Loader::helper('form/attribute');
$af->setAttributeObject($ui);
foreach($attribs as $ak) {
print '<div class="ccm-profile-attribute">';
print $af->display($ak, $ak->isAttributeKeyRequiredOnProfile());
print '</div>';
} ?>
</fieldset>
<?php } ?>

Any input will be greatly appreciated. Cheers.

lifestyle1
 
A3020 replied on at Permalink Best Answer Reply
A3020
You'd need to change the $attribs array. Here's an example:

$set = AttributeSet::getByHandle('some_set');
$attribs = $set->getAttributeKeys();
foreach($attribs as $ak) {
   if(!$ak->isAttributeKeyEditableOnProfile()){
      continue;
   }
   echo $af->display($ak, $ak->isAttributeKeyRequiredOnProfile());
}
lifestyle1 replied on at Permalink Reply
lifestyle1
Thank you akodde, I knew what it needed to do but couldn't get their on my own.
You're answer is spot on, thanks again I really appreciate it.