How to add a SELECT user attribute key from a package
Permalink 1 user found helpful
I've just burned half a day trying to find out how to do this so hopefully an end-to-end example (of which there are too few for C5) will save others much time.
This will add a SELECT attribute type to users from your package:
This will add a SELECT attribute type to users from your package:
$attr = \Concrete\Core\Attribute\Key\UserKey::getByHandle('providertype'); if( $attr === null ) { $attr = \Concrete\Core\Attribute\Key\UserKey::add('select', array( 'akHandle' => 'userprovidertype', 'akName' => t('Provider type'), 'akIsSearchable' => true ), $pkg); $option = \Concrete\Attribute\Select\Option::add( $attr, 'Apple', 0); $option = \Concrete\Attribute\Select\Option::add( $attr, 'Pear', 0); $option = \Concrete\Attribute\Select\Option::add( $attr, 'Banana', 0); }
Just spent half a day myself before I found this...
But just noticed that Option::add is deprecated.