Forum .LRN Q&A: Re: how to add a new field in the registration page??? plz help

Dinesh,

to extend user registration fields, we use AMS package (Attribute Management System). See the AMS documentation "AMS lets developers (via tcl api) and site wide administrators (via the the ams admin UI) add attributes to acs_object"

The user bio is attribute sample of person object.

You can create many attributes you want without modifying the model of data.

How To:

1) Go to AMS instance and choose the object -PERSON
2) On UI create a new AMS Lists (a group name of "extend fields")
3)Create each Attribute you want. Choose name, Widget, etc.
4) Map Attributes to your new AMS Lists
5)To show the attributes on the registration form, edit the acs-subsite/lib/user-new.tcl

sample:

......
# Pre-generate user_id for double-click protection
set user_id [db_nextval acs_object_id_seq]

ad_form -name register -export {next_url user_id return_url} -form [auth::get_registration_form_elements]

++ ad_form -extend -name register -form [ams::ad_form::elements -package_key "acs-subsite" -object_type "person" -list_name "person_extra_info"]

if { [exists_and_not_null rel_group_id] } {
…..

5) now in the same archive modifies the on-sub action:

......
switch $creation_info(account_status) {
ok {
# Continue below
}
default {
# Display the message on a separate page
ad_returnredirect [export_vars -base "[subsite::get_element -element url]register/account-closed" { { message $creation_info(account_message) } }]
ad_script_abort
}
}

++ ams::ad_form::save \
++ -package_key "acs-subsite" \
++ -object_type "person" \
++ -list_name "person_extra_info" \
++ -form_name "register" \
++ -object_id $user_id

} -after_submit {
.......

6) in similar way modifies other archives to display/edit aditional attributes

This is actually something which should make it into core for 5.4. Once it is approved, we could add this AMS list to contacts as the default person form (at the moment there is a default person form per contacts instance, maybe we could change this to a default person form in AMS per subsite).