XF 1.1 promotion when user "logged in"

Weppa333

Well-known member
Dear all,

I see that there is an option (checkbox) in the usergroup promotion for promoting a user "when logged in". It's the second checkbox, just after "user is a guest".

AFAICS, the promotion is a cron that runs once a day,
so I'm not sure what this checkbox actually does ( is the user connected when the cron runs ? Makes no sense :) )

Could someone explain it to me ?
 
Last edited:
The promotion cron runs every 1 hour. It will select users who have been active within the last 2 hours.

If they have been active within the last two hours, and they meet the criteria you set, they will be promoted.
 
I must admit I did not yet test my promotion when the user is logged off.
The checkbox seemed to imply (to me) that it would be running "live". (It even seems it does run live in 1.2)

But for what I need, as long as it only processes "active" accounts, it's more than enough.

I'll try this right away.

I run the cron (just to be safe)
I create two users
I login with one of them, not the other
I log off (and wait 15 minutes)
I set up a promotion with "user logged in" checked + matching criteria for the two users I created
I run the cron

And the cron is supposed to handle the single user that did login. At least that's the expected behavior :)

I'll let you know how it goes, thanks again !
 
damned, freshly created users (thru ACP) have "recent activity" set to user creation date.

I'll simply wait a few hours (letting the cron run dry) before starting my tests.
 
This is not true, at least for 1.1.
I just tried a promotion, not checking "user logged in" as you said, and it simply promotes everyone, regardless of their last loggin time. In my case, it did promote people who have not connected since yesterday
I'll now try with the "logged in" flag, but I guess it only does what it says it does ; upgrade if logged in when the cron runs...
 
The checkbox does not do that :p

It verifies if the user has a user ID or not. Every user has a user ID so it will not make a difference to your promotion.

Does that make sense?

As for 1.1 I will check the code later. Maybe it changed in 1.2.
 
Hi Mike,
Thanks for the clarification. 3 days is OK for my needs too, I'm sorry to ask so many questions but I have to be sure what this promotion does as it will affect a 50K+ users database ( I'm doing my tests on an offline backup right now, and every time the promotion fails to do what it is supposed to do, it's a pita :) )

Could you point me to the file containing the code that checks for that 3 days window ? I cannot find it in /library ?
 
Last edited:
Here's the snippet of code that fetches the users:

PHP:
        $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
        ));

86400 seconds = 1 day * 3 = 3 days.

So only users who have been active in the last 3 days are selected for promotion.

Can be seen in library/XenForo/CronEntry/UserGroupPromotion.php
 
Top Bottom