Group Attributes
Permalink
Hello everyone --
First, a warning: I am a total PHP hack. I do not know what I am doing.
My client is looking to have certain attributes be specific to certain groups. I've seen several posts in this forum of people looking for similar functionality, so I thought I would post what progress I've made in case someone can build on it and make it better. I'm sure it's very unsophisticated and kludgy.
The idea I had was to prefix the attribute handle with the group it is specific to. For example, all attributes for the "parent" group begin with "parent_", like "parent_address" and "parent_cell". Then when the login script checks for any new, unfilled attributes, I just tack on those attributes to the list. So the user doesn't fill them out upon initial registration, but rather at the first real login. Seems like an ok compromise.
I copied the login.php file from /concrete/controllers into my /controllers directory, and copied the finishLogin function from concrete/core/single_pages/login.php into my new file.
I then added the following:
First, a warning: I am a total PHP hack. I do not know what I am doing.
My client is looking to have certain attributes be specific to certain groups. I've seen several posts in this forum of people looking for similar functionality, so I thought I would post what progress I've made in case someone can build on it and make it better. I'm sure it's very unsophisticated and kludgy.
The idea I had was to prefix the attribute handle with the group it is specific to. For example, all attributes for the "parent" group begin with "parent_", like "parent_address" and "parent_cell". Then when the login script checks for any new, unfilled attributes, I just tack on those attributes to the list. So the user doesn't fill them out upon initial registration, but rather at the first real login. Seems like an ok compromise.
I copied the login.php file from /concrete/controllers into my /controllers directory, and copied the finishLogin function from concrete/core/single_pages/login.php into my new file.
I then added the following:
// Verify that the user has filled out all // required items that are required on register // That means users logging in after new user attributes // have been created and required will be prompted here to // finish their profile $this->set('invalidRegistrationFields', false); Loader::model('attribute/categories/user'); $ui = UserInfo::getByID($u->getUserID()); $aks = UserAttributeKey::getRegistrationList(); // HERE IS WHERE WE CREATE A NEW LIST OF AKs // get every attribute? $attributes = UserAttributeKey::getList(); // get every group the user is in $groups = $u->getUserGroups(); // for each group the user is in
Viewing 15 lines of 40 lines. View entire code block.