How to add custom user attribute programmatically from package
Permalink
Updated: problem solved with this code.
Adding "Membership Type" custom user attribute and populate this with 2 options (Publisher and Reader). Also, this attr is set as required on register.
Regards, Nick
Adding "Membership Type" custom user attribute and populate this with 2 options (Publisher and Reader). Also, this attr is set as required on register.
public static function installUserMembershipTypeKey($pkg) { $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); $service = $app->make('Concrete\Core\Attribute\Category\CategoryService'); $categoryEntity = $service->getByHandle('user'); $category = $categoryEntity->getController(); $key = $category->getAttributeKeyByHandle('membership_type'); if (!is_object($key)) { $key = new UserKey(); $key->setAttributeKeyHandle('membership_type'); $key->setAttributeKeyName('Membership Type'); $key->setIsAttributeKeySearchable(false); $key->setAttributeKeyEditableOnRegister(true); $key = $category->add('select', $key, self::setSelectSettings(['Publisher', 'Reader']) , $pkg); }
Viewing 15 lines of 39 lines. View entire code block.
Regards, Nick
Thank you! I think that the solution you proposed is the best way.
this was helpful today thank you
It seems the first URL has strangely changed to:
https://documentation.concrete5.org/developers/packages/concrete5-ci...
Note the '-1' ad the end. The original returns a page forbidden after logging in :(
https://documentation.concrete5.org/developers/packages/concrete5-ci...
Note the '-1' ad the end. The original returns a page forbidden after logging in :(
https://documentation.concrete5.org/developers/packages/concrete5-ci...
https://documentation.concrete5.org/developers/appendix/concrete5-ci...