Hi Kumar,
am at the wall with the same problem you hard, am not having success
below is my code, its from the account type table that i have defined 
account type
Any assistance is so much appreciated.
Thank you


/dbypy file
db.define_table('account_type', 
  Field('name', 'string', length=20, notnull=True, label='Account Type'),
  migrate=True,
  format='%(name)s'
  )



#adding extra fields required on registration

auth.settings.extra_fields['auth_user']= [
    Field('country', 'reference country'),
    Field('district', 'reference district'),
    Field('account_type', 'reference account_type', label='Account Type')
    ]




default.py
def __add_user_membership(form):
    group_id = auth.id_group(role=form.vars.account_type)
    user_id = form.vars.id
    auth.add_membership(group_id, user_id)
    

def user()
  """
    auth.settings.register_onaccept = __add_user_membership

    return dict(form=auth())












On Thursday, December 22, 2011 at 1:03:56 AM UTC+3, Chandrakant Kumar wrote:
>
> better version :
>
> def __add_user_membership(form):
>          group_id = auth.id_group(role=form.vars.user_type)
>          user_id = form.vars.id
>          auth.add_membership(group.id,user_id)
>
> On Thu, 22 Dec 2011 01:52:50 +0530, Anthony <abas...@gmail.com 
> <javascript:>> wrote:
>
> > You can use an auth.settings.register_onaccept function, which could use
> > auth.add_membership() to add the appropriate membership for the new user.
> >
> > Anthony
> >
> > On Wednesday, December 21, 2011 3:00:20 PM UTC-5, Chandra wrote:
> >>
> >>
> >> I'm attempting to add a user to a group , depending on the role he chose
> >>  from a dropdown list.
> >>
> >> for e.g., In the register form user is presented an option of choosing
> >> user type 1. individual 2. organisation
> >>
> >> how do i add the user to the appropriate group depending on his  
> >> selection?
> >>
> >> (i went through the group archives, and one solution was to use
> >> request.args, but i want to use single register link)
> >>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to