DjangoBB

Django based forum engine

  • You are not logged in.

#1 Dec. 6, 2012 19:09:20

tzot
Registered: 2012-12-05
Posts: 5
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

Hello. I have set up a djangobb project on a site, and through the admin interface I have setup three Groups, and some Categories where the appropriate Groups have permissions.

However, when a new user is registered, they haven't any default group, so they have no permissions at all.
How can I setup a new User to belong to a specific Group by default? Note that I might have missed some step of the forum setup, all the documentation I found was scattered and mostly incomplete.

Thanks in advance.

Offline

#2 Dec. 7, 2012 16:41:54

slav0nic
DjangoBB Developer
From: Ukraine
Registered: 2009-10-25
Posts: 382
Reputation: +  5  -
Profile   Send e-mail  

Default group for new users

More correct question: “as do this in django?”

Check django-registration (or what you uses?) registration.signals.user_registered signal and group in handler

Offline

#3 Dec. 28, 2012 11:55:21

tzot
Registered: 2012-12-05
Posts: 5
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

I'm sorry, I'm very new with django. I assumed I could do that from the web administration interface.
I'm using a basic_project forum and the registration module, with so far untouched code. Where would I add code so that upon user registration, the user becomes automatically a member of the “Users” group?
Searching the web, I found that I got to do something along the lines:

from registration.signals import user_registered
user_registered.connect(new_user_created)
Where can I add this?
Obviously the new_user_created function is where I add the logic for making the User object a member of the Users group, but I still don't know how to make what I want.
This StackOverflow answer seems related to my issue.

Offline

#4 Dec. 28, 2012 12:26:05

tzot
Registered: 2012-12-05
Posts: 5
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

Since the documentation says “connect the signal anywhere in an imported module”, I added the code in local_settings.py (I imagine it's a gross misuse of the file but it works; I will try to make it more “clean” somehow). The function “new_user_created” works now.
So I have to do something like

user.groups.add(users_group)
and the only thing I need to find out is, well, how to set “users_group” to be the group “Users”. Like I said, I'm very new to Django.

Edited tzot (Dec. 28, 2012 12:26:50)

Offline

#5 Sept. 16, 2014 20:43:08

hevin
Registered: 2014-09-16
Posts: 1
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

put this code in models.py of your custom app:
from registration.signals import *
from django.contrib.auth.models import Group
from django.dispatch import receiver

# Create your models here.

@receiver(user_registered)
def add_group_to_user(sender, user, request, **kwargs):
defaultgroup = Group.objects.get(name = ‘normaluser’)
if defaultgroup:
user.groups.add(defaultgroup)

'normaluser' is the name of your default group

Offline

#6 Feb. 2, 2015 11:25:03

willholt627
Registered: 2015-02-02
Posts: 1
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

had thought about it, but did not grow together, in principle, it is easier than the current version, can be in the distant future, and implements

Offline

#7 Aug. 24, 2017 07:53:54

maryhaugen
Registered: 2017-08-18
Posts: 4
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

Magento U is a vital resource for the Magento community with over 50,000 registrations for courses on the Magento U website during the past 12 months alone. We are therefore excited to announce the launch of a new and improved learning management system (LMS) for My Magento U. This new system is another example of our commitment to making Magento easier to work with and to continually improving our training offerings.
Magento 2 extensions - XML Sitemap for Magento 2 - Social Login for Magento 2
Magento Extensions Review

Edited maryhaugen (Aug. 24, 2017 07:56:45)

Offline

#8 Sept. 27, 2018 05:42:46

XRumerTest
Registered: 2018-09-22
Posts: 131
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

Hello. And Bye.

Offline

#9 Oct. 4, 2018 03:45:39

XRumerTest
Registered: 2018-09-22
Posts: 131
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

Hello. And Bye.

Offline

#10 Oct. 6, 2018 16:44:39

XRumerTest
Registered: 2018-09-22
Posts: 131
Reputation: +  0  -
Profile   Send e-mail  

Default group for new users

Hello. And Bye.

Offline

Board footer

Moderator control

Powered by DjangoBB

Lo-Fi Version