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

XF 1.1 Query To Update All Users With 500 Posts To New User Group

Discussion in 'XenForo Questions and Support' started by Brent W, Apr 20, 2012.

  1. Brent W

    Brent W Well-Known Member

    I need an SQL query that I can run that will change all members user group who have 500 or more posts.
  2. borbole

    borbole Well-Known Member

    Have you tried the Group Promotion?
  3. Brent W

    Brent W Well-Known Member

    Yes but they don't seem too be moving everyone with 500 posts over and they add them as secondary user group.

    FYI: I need the query to only move members in the Registered User Group with 500 posts.
  4. borbole

    borbole Well-Known Member

    First of all make a backup of your users table and run this query:

    UPDATE xf_user SET user_group_id = x WHERE message_count = 500;
    Replace x with the group id that you want to move the users with 500 posts and xf_ with whatever prefix you are using for your db tables.

    P.s. You might want to run the Rebuild User Caches as well after the query. btw.
  5. Kevin

    Kevin Well-Known Member

    OT curiosity question... are you finding something that is easier to do by having them in a new primary group instead of a secondary group? With The-Forum-That-Shall-Not-Be-Named (OK, OK, vBulletin) I used to use a lot of primary groups but with XF I *think* so far I can get away with just using secondary groups.
  6. Brent W

    Brent W Well-Known Member

    Shouldn't it be this:

    UPDATE xf_user SET secondary_group_ids = 9 WHERE message_count > 500;
    As I want to update it for everyone with greater than 500 posts.
  7. Brent W

    Brent W Well-Known Member

    I am going to try to use secondary usergroups for this. I am still new to the user group setup that xenForo uses.
  8. Brogan

    Brogan XenForo Moderator Staff Member

  9. Brent W

    Brent W Well-Known Member

  10. Kevin

    Kevin Well-Known Member

    Before changing their primary groups, definitely check out that guide Brogan posted. The permissions can be a bit of a mind bender at times but after while it makes sense.
  11. bambua

    bambua Well-Known Member

    I was originally trying to do everything with the primary user groups on my site like I did in vb, but with the XF permissions model it's really hard to make this work sometimes. That link Brogan posted helped me a lot.
  12. borbole

    borbole Well-Known Member

    You did not say that you wanted to change the secondary groups. That can be done with the group permissions which I already mentioned. Also you said that you wanted to move users with 500 posts as per your other post above.

    FYI: I need the query to only move members in the Registered User Group [B]with 500 posts[/B].[/quote]
    Anyway, to move all users with 500 posts and above use this operator: >=
  13. Brent W

    Brent W Well-Known Member



    Thanks but this is my original post:

    I originally wanted primary usergroup but now that I understand secondary better I went with that.[/CODE][/quote]
  14. Edrondol

    Edrondol Well-Known Member

    Okay, I'm going to piggyback on this thread because I need similar. I tried adding a promotion, but that didn't seem to work. I want to ADD a secondary user group if they meet a specific criteria.

    The pertinent data is:

    Current secondary_user_groups may include multiple but all have #31.
    I want to add #35 to their secondary_user_groups.
  15. Rob

    Rob Well-Known Member

    I had to move every single user with a certain value in a profile field into a secondary usergroup. The way I achieved this was to first create a usergroup promotion to do what I needed. Next, find this file:- library/XenForo/CronEntry/UserGroupPromotion.php

    Remove the red code to get rid of the last_activity restriction and match all users:

            $users = $userModel->getUsers(array(
                'user_state' => 'valid',
                'is_banned' => 0,
                'last_activity' => array('>', XenForo_Application::$time - 86400 * 3)
            ), array(
                'join' => XenForo_Model_User::FETCH_USER_FULL
    Then you can manually run the task to force immediate promotions:
    Admin CP -> Tools -> Cron Entries -> User Group Promotions -> Controls: Run

    Before you run the cron add these lines to your config.php file
    ini_set('memory_limit', -1);
    ini_set('max_execution_time', 5000);
    Dont forget to remove those lines and put the line of code back into UserGroupPromotion.php when you are done running the cron.

    PS. You have Jake to thank for the above, I just took his advice
    Brent W likes this.

Share This Page