Posted by gustav on December 1, 2007 at 11:00pm
Jump to:
| Project: | User types |
| Version: | 5.x-1.x-dev |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Do you have some documentation of what this module does? It sounds potentially useful.
Comments
#1
REPORT ON USER_TYPES MODULE
a. WHAT DOES IT DO?
It gives you the power to make custom profiles for certain types of users. This module makes it possible to define custom form fields (profile module must be enabled). Then it let’s you determine for which profiles this field will be active. For example: If we want a field where you can enter who’s your favorite band, you create this field like you would normally do in admin/user/profile/add/textfield and at the bottom you can choose for which user types (which you defined earlier in admin/user/user_types) this field will be active using the checkboxes. It’s that simple.
b. HOW DO YOU USE IT?
i. CREATE, CHANGE AND DELETE A USER TYPE
You start with creating user types in admin/user/user_types. In the list you’ll see which types you’ve created earlier. After clicking the second tab ‘add user type’ you can enter the name of the user type you want to create in the textfield. The third tab is used to name the ‘untyped‘ (i.e. users without a type) users.
You can also change/delete the name of the type later, by clicking one of the types in the list. Clicking the edit tab will give the change/delete options.
ii. CREATE A CUSTOM FORM FIELD FOR A TYPE
You go to admin/user/profile and you chose what type of profile entry you want, choose a category to group the new one by (you‘ll have to create categories to group the fields together), a title, a form name, etc… At the bottom you will be able to choose for which types the field will be active.
The last checkbox, ‘Show in quick view’ enabled will give you a view of the fields and their submitted data in quick view when viewing the list of all the users in a type (admin/user/user_types/type_name_example). When not enabled you will only see the field and its data when clicking detailed view (which you’ll see clicking the tab next to it).
iii. ADD A USER TO A TYPE
This can only be done by creating new users. Existing users cannot be given a type. Only new users can get a type. When creating an account, you choose which type you want to be and you fill in the custom fields for your type.
This causes a problem when you have created custom fields before you installed the user_type module and you want the earlier created fields to be part of one of the newly created types. This will cause existing users to loose the ability to update these fields. Since you can’t give a type to an existing user, and you’ve set the field to be associated with a user of the certain type, then that means that all submitted data won’t be accessible anymore by that user. The data is still accessible by the profile module and will be shown on the profile page. Reason: The user type module causes the user edit form to display nothing (see 'how does code work' for more).
Maybe some extending of the module is needed to give existing users a type. This will solve the problem above.
c. HOW DOES THE CODE WORK
This is the menu hook. It add this to menu tree in:
Calls for user_types_admin_page (which creates the html for the list with types, this list is generated by the function user_types_list() who queries the database).
List (default) tab which shows the types created in user_types_admin_page.
Calls for the form user_types_settings(which generates the form for changing the name for ‘untyped’ users)
Calls for the form user_types_add_form(which generates the form for entering new types)
Calls for user_types_type_page( array($user_type_id)) which gives an overview of the users of this type and the fields enabled for this type and their input data (if the quick view checkbox was enabled).
List (default) tab which show the above topic. Calls for Calls for user_types_type_page( array($user_type_id)) as well.
List (default) secondary tab which gives a quick view of fields and their data. Calls for user_types_type_page( array($user_type_id)) as well.
Gives all custom fields and input data by user. Calls for user_types_type_page( array($user_type_id), TRUE). Second parameter is TRUE so the detailed view is created.
Calls for the user_types_edit_form (which edits the name of the type).
Calls for user_types_delete_form, which deletes the type.
Queries the table user_types_type for all the available types. And puts it in an array and returns this.
Gets called in user_types_form_alter($form_id, &$form) and user_types_user($op, &$edit, &$account, $category = NULL). Gets the user_type_id by looking at the active topic in the menu and returns it.
This is the form_alter hook . The forms it changes:
user_types_profile_fields table (holds for which type which forms are enabled) gets queried to get the default value for the checkboxes. And it queries user_types_quick_view to see if the quick view checkbox is enabled. The extra forms are constructed and added to the form. (checkboxes to set for which type the form will be active and a check box for quick view)
Query on user_types_user table to see what type of user you are dealing with. Sets it to -1(=‘untyped’) if user is not found.
Removes form fields for this type. Removes the empty fieldsets. Author: ”We can not remove a category added by profile module, so the best we can do is confirm the page is supposed to be empty.” This is the reason why a problem arises earlier discussed in b.ii.
This the user hook(). It acts when:
Insert : It inserts in the database which kind of type a user is. If we would extend the module to give the existing users a type we will have to act on the same table.
It is the submit function for the fields we added in the profile_field_form form. Updates the table by deleting all fields corresponding with the fid and then inserts for which types the form is enabled, setting ‘enabled’ to 1 and the others to 0. Also updates the quick_view table in the same manner.
Generates html for the list generated by user_types_list() and outputs this on the admin page.
Form for inputting the name for ‘untyped’ users.
the submit function for the above form. Sets the variable with variable_set and clears the cache.
Form to add a type.
Submit function for the above. Inserts new type into user_types_type.
Generates form to edit the name of the type. And to delete it.
submit function for the above. Updates the database with new name.
Generates the delete form.
Submit function for the delete form.
Generates the detailed view or quick view. Queries the database to know if the fields have to been given in quick view or in detailed view and this is done by user.
d. CONCLUSION
Available:
Not available:
#2
So that's what User types does. Thanks!
#3
Hmm... such a great and useful module. Would there be a way to have a multiple select list so users can choose more than one?
#4
I've actually found it easier to designate a category and then make a checkbox for each option. This may not be the best way, but it works for me. Any answers still would be appreciated.
Thanks for the module.
#5
Great documentation domidc! I'll update the project page as soon as possible and add it also to the readme pages!
#6
Added more clear description on project page. Lot's of this text has been included in the help pages of this module, will be commited soon. Thanks!
#7
Automatically closed -- issue fixed for two weeks with no activity.