Thanks massimo,
Apologies for being such a newbie, just like the user id can be got from
the form using the* form.vars.id <http://form.vars.id>*, will the group_id
= form.vars.account_type.
My challenge is getting the account_type value from the registration form
when the user registers.

Thanks again for your help

On Sat, Nov 19, 2016 at 11:20 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> auth.settings.register_onaccept.append(lambda form:
> auth.add_membership(user_id=form.vars.id, group_id = group_id1) and
> auth.add_membership(user_id=form.vars.id, group_id = group_id2))
>
> instead of group_id = ... you can specify the name of the group role =
> 'groupname'
>
>
> On Saturday, 19 November 2016 07:48:30 UTC-6, Joe Lwe wrote:
>>
>>
>> Hi Pierro,
>> I have defined custom groups in db(buyer,seller, individual,
>> non-individual), i want all users who sign up to belong to one or two of
>> the groups that have been defined.
>>
>> My sign up form is as below/attached
>> Thank you so much for the web2py project and your help
>>
>>
>>
>> On Friday, November 18, 2016 at 9:14:52 PM UTC+3, Massimo Di Pierro wrote:
>>>
>>> not sure where this is called but this is wrong.
>>>         user_id = request.vars.username
>>>         auth.add_membership(group_id,user_id)
>>> the username is probably not a user_id
>>> Can you tell us more about where this is called and what username and
>>> account_type are for you?
>>>
>>>
>>>
>>>
>>> On Sunday, 13 November 2016 05:17:11 UTC-6, Joe Lwe wrote:
>>>>
>>>>
>>>> def add_user_memberhip():
>>>>     if auth.settings.register_onaccept==True:
>>>>         group_id = request.vars.account_type
>>>>         user_id = request.vars.username
>>>>         auth.add_membership(group_id,user_id)
>>>>         response.flash="You have been added to"+group_id
>>>>     else:
>>>>         response.flash='An Error has accured'
>>>>
>>>> Am trying to get user added to group in variable account_type upon
>>>> registration, but nothing is working
>>>> Just declared the function above, below user()
>>>> Thanks so much
>>>>
>>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/rPjY4kGH0EA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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