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

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

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

Code:
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.
 
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.
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.
 
First of all make a backup of your users table and run this query:

Code:
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.

Shouldn't it be this:

Code:
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.
 
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.

I am going to try to use secondary usergroups for this. I am still new to the user group setup that xenForo uses.
 
I am going to try to use secondary usergroups for this. I am still new to the user group setup that xenForo uses.
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.
 
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.
 
Shouldn't it be this:

Code:
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.

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.

Code:
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: >=
 
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.

Code:
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: >=
[/CODE][/quote]

[/CODE][/quote][/CODE][/quote]

Thanks but this is my original post:

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

I originally wanted primary usergroup but now that I understand secondary better I went with that.[/CODE][/quote]
 
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.
 
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

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

Rich (BB code):
        $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
Code:
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
 
Top Bottom