1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SQL query to assign user group to all memners

Discussion in 'XenForo Questions and Support' started by fredrikse, Jan 7, 2013.

  1. fredrikse

    fredrikse Active Member


    What would an SQL query look like that assign all members to a secondary user group?
  2. Chris D

    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.
    Jake Bunce likes this.
  3. fredrikse

    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.
  4. Chris D

    Chris D XenForo Developer Staff Member

    What I've described will do that.
    fredrikse likes this.
  5. fredrikse

    fredrikse Active Member

    I will try that on my test user.
  6. fredrikse

    fredrikse Active Member

    Verified and works great! (y)
    Chris D likes this.
  7. fredrikse

    fredrikse Active Member

    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:


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

    fredrikse Active Member

    Are user groups referring to primary or secondary user groups?
  9. Chris D

    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.
    Jake Bunce likes this.
  10. Chris D

    Chris D XenForo Developer Staff Member

    Jake Bunce likes this.
  11. fredrikse

    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.
  12. Chris D

    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.
  13. fredrikse

    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?
  14. fredrikse

    fredrikse Active Member

    Strange. No result yet. I triggered the cron job for usergroup promotions.
  15. fredrikse

    fredrikse Active Member

  16. Chris D

    Chris D XenForo Developer Staff Member

    This is important:

    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.

    Attached Files:

    Jake Bunce and fredrikse like this.
  17. fredrikse

    fredrikse Active Member

    It worked perfectly. Thanks for helping me out on such short notice, Chris! :)
    Chris D likes this.

Share This Page