this issue is as per discussion on civicrm-dev list
1. Add new setting for Profiles : "Create CMS User"
2. If this is enabled, the Profile form fieldset is "enhanced" as
follows when the form is displayed AND the visitor is NOT logged in to
- Add checkbox: "Create an account?"
- If checked, display fields for entering Username, Password,
(The profile must include an Email Address, or this feature is suppressed)
3. When the profile is submitted, we would invoke the same Drupal API
used when a new user registers "normally". This should mean that "post
user creation processes" configured for a given site would be
triggered (e.g. sending welcome emails, etc.)
check drupal api: http://api.drupal.org/api/HEAD/function/drupal_execute
4. Error Handling -
- We need to handle the case where a User with this Username and/or
Email already exists. We could either return an error message and not
submit the profile form (tell them to login, etc.). Or, we could
bypass creating the account. If we bypass creating the account, we
mIght need to tell them that a new user account was NOT created
because an account already exists...and to use their existing login...