adding user attributes

Permalink
Hi,

I am pretty new to building packages, and I have a question about adding custom user attributes. How do I know which properties to set for a given attribute?

I found this in another package, which seem to work - but I would like to know how to build these not just from guessing, as now I would like to build a birthday attribute with date and not time?

Any ideas?

The name attribute is attached

$euku = AttributeKeyCategory::getByHandle('user');
        $euku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE);
        $uset = $euku->addSet('user_set', t('User Info'),$pkg);
$textt = AttributeType::getByHandle('text'); 
        $sblname=UserAttributeKey::getByHandle('last_name'); 
      if( !is_object($sblname) ) {
           UserAttributeKey::add($textt, 
           array('akHandle' => 'last_name', 
           'akName' => t('Last Name'), 
           'akIsSearchable' => false, 
           'uakProfileEdit' => true, 
           'uakProfileEditRequired'=> true, 
           'uakRegisterEdit' => true, 
           'uakProfileEditRequired'=>true,
           'akCheckedByDefault' => true,

pixel8
 
ssdscott replied on at Permalink Reply
ssdscott
Hi,

In case you hadn't already figured this out:

The attributes you can set (as seen in the example code you found) mimic the user attribute fields that are found in the Dashboard / Users / Attributes / Add Attribute screen. Seeing them presented this way helped me understand what each one was for - hopefully it helps you, too.

On the Date without Time question, if you use the UI to create a new Date/Time attribute, there's a question at the bottom, "Ask user for" where you can pick "Date Only" as an option. If you check out your concrete directory for concrete/core/models/attribute/types you'll find date_time.php, which is where the default C5 date time attribute type is implemented. (At least, that's true for 5.6!)

Hope this helps...