SQL query to assign user group to all memners

Chris D

XenForo developer
Staff member
Do it the easy way.

Create a usergroup promotion with some arbitrary criteria such as "User State Is: Valid" that promotes them to the desired usergroup.

That would effectively make everybody a member of the usergroup. unless they are awaiting approval. In which case, as soon as they are approved or have confirmed their e-mail they will get automatically promoted anyway.
 

fredrikse

Active member
I'm about to migrate my vBulletin forum this week. All members will be members och the group registered. Then I also want them all to become members och the member group. So this is something that should effect all members.
 

fredrikse

Active member
Do it the easy way.

Create a usergroup promotion with some arbitrary criteria such as "User State Is: Valid" that promotes them to the desired usergroup.

That would effectively make everybody a member of the usergroup. unless they are awaiting approval. In which case, as soon as they are approved or have confirmed their e-mail they will get automatically promoted anyway.
It turns out that I was a little bit fast in verifying the result last time. The usergroup promotion is not working as expected (probably because I'm doing something wrong).

These are the criterias that I use:

usergroup_promotion.png

When criteria is true the user will be member of the usergroup member. Am I missing something here?
 

Chris D

XenForo developer
Staff member
Are you trying to put all registered group users into the members group?

If so the second usergroup option is unnecessary. It won't attempt to promote someone to a usergroup they're already in.

Explain in detail what you're trying to do and I'll help you come up with the right options.
 

fredrikse

Active member
My permission system is based on the groups registered, member and premium. All new members get the membership of registered right away. After ten pre-moderated posts they are transferred to the member group with "normal" account restriction for that type of group. In this scenario when I'm migrating my forum I want all existing users to become member of the member group. That's really what I'm trying to achieve.
 

Chris D

XenForo developer
Staff member
Ok. From the beginning.

Assuming all existing users are in the "registered" group already...

1) Admin CP > Users > User Group Promotions > Create New Promotion
2) Title: Whatever. Add user to groups check: "Member"
3) Apply this promotion while: User state = Valid
4) User is a member of any of these groups = Registered

And that's it.

That should promote any user currently in the Registered group to be also in the Member group.
 

fredrikse

Active member
Alright. I'll try that! Maybe the problem was that I had the criteria set that a member should not already be a member of the member group?
 

fredrikse

Active member
I found about 30 records in the database table xf_user_group_promotion_log. There should be more records if all had gotten the right membership. I took some of the user IDs from this table at verified that the they had been granted membership in member group.

I found these thread discussing the same subject:

http://xenforo.com/community/threads/usergroup-promotion-runs-but-no-usergroup-change.42984/#post-462444

http://xenforo.com/community/threads/user-group-promotions-only-run-once.31276/#post-357121
 

Chris D

XenForo developer
Staff member
This is important:

Note that the cron only updates users who have been active in the last 72 hours, so there may be a delay for some users despite manually running the cron.
There's a code edit to get around that. Would be good to make that code change now to get done what you need to, then revert it back to normal.

I don't know where the code edit is. Like all good things, it was posted by Jake so I will see what I can find.

EDIT: It's ok, I have worked it out myself.

Back up this file: library/XenForo/CronEntry/UserGroupPromotion.php

And replace it with the one attached.
 

Attachments

Top