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

XF 1.1 promotion when user "logged in"

Discussion in 'XenForo Questions and Support' started by Weppa333, Sep 1, 2013.

  1. Weppa333

    Weppa333 Active 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: Sep 1, 2013
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    It will check for promotions on session creation instead of waiting for the cron job to run. This'll allow your promotions to reflect correctness earlier and give any additional permissions to the user faster.
    Weppa333 likes this.
  3. Weppa333

    Weppa333 Active Member

    So checking this simple checkbox creates a "very special promotion" that does not run in the cron ?
    It's even greater than I thought :)
  4. Weppa333

    Weppa333 Active Member

    Oh and by the way, THANKS jeremy for a faster than light answer :)
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    No, the promotion will still be applied via promotions if they meet the criteria post session creation. This just places a secondary check for meeting criteria on session creation.
  6. Weppa333

    Weppa333 Active Member

    Holy cow it's exactly what I need. OH WAIT this is why I moved to XF in the first place :)
  7. Brogan

    Brogan XenForo Moderator Staff Member

    Have you translated the phrases?

    There is no "connected" criteria, only "User is logged in".
  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    The functionality I described is actually in 1.2 by default, and isn't actually a criteria. My apologies on that part!
  9. Weppa333

    Weppa333 Active Member

    Thanks , what is the behavior in 1.1 ? Also applies the check at session creation ?

    Indeed my admin panel is translated :)
  10. Jeremy

    Jeremy XenForo Moderator Staff Member

    No, 1.1 only applies the promotions via the Cron Job.
  11. Weppa333

    Weppa333 Active Member

    Then we're back at question 1 : what does it do ? If it runs via cron it cannot possibly know if a user is logged in or not ...
  12. Weppa333

    Weppa333 Active Member

    On my install (I of course tried before asking) it does nothing that can be seen.

    I might be doing something wrong tough. If someone took the time to add the option, it probably does something :)
  13. Jeremy

    Jeremy XenForo Moderator Staff Member

    It may be a translated "user is logged in" criteria as Paul state. Other than that, you can disable add-ons one by one to find which one adds it and ask the author.
  14. Weppa333

    Weppa333 Active Member

    It's not a mod, it's plain stock xf 1.1.5 ...

    I'll look into the code ...
  15. Weppa333

    Weppa333 Active Member

    I'm back with this,
    Quickly looking at the code grep'ping for "promotions", there isn't anything talking about promotions anywhere else than in the cron

    And this option lies in 1.1.5 I verified twice.

    There's no shame in telling me "this option does nothing at all, it was unfinished", if that's indeed the case, it would help me knowing it :)

    So I'm asking again, what does "when logged in" promotion checkbox does in XF 1.1.x ?
    I created promotions with that flag and nothing happens when the users logs in.
    (it does if I run the cron manually at that time tough)

    If someone from XF confirms this options does not work at all, I could "quickfix" by running that cron every mintu for example.

    I hope you're not dropping 1.1.x support too fast :( I'll upgrade in the coming months but it's simply not possible right now
  16. Chris D

    Chris D XenForo Developer Staff Member

    There isn't anything unfinished about it.

    I assume you're talking about the criteria underneath the User Criteria tab?

    "User is logged in"?


    In the context of User Group Promotions, the user will meet the criteria if they are currently logged in (e.g. having a valid session) at the time of the Promotion cron entry running.

    This seems like it might not be what you want to do.

    It's worth noting, however, that the Cron by default runs every hour, and you can adjust it to run as frequently as possible. So you may be able to tweak various values (e.g. online session timeout) that might catch most/all of the users as they are logged in.

    Would be worth sense checking what you actually want to achieve, however, as this kind of thing I haven't seen requested before...

    It's worth bearing in mind that the criteria here is used for much more than just Trophies and Promotions etc.

    The main benefit of this particular criteria is for Notices. You may only want to show a Notice if a user is logged in. Notice criteria is analyzed at page load.
  17. Mike

    Mike XenForo Developer Staff Member

    Regarding User is logged in...

    I know @Chris Deeming's post explained a bit further, but I just want to make it clear. Maybe I'm mis-understanding the quoted sentence (as the rest of the post seems correct), but it doesn't work like that --^.

    It's a criteria so it applies to multiple types of things. It's meaningless in the context of a promotion. It means that the user is a registered user but you can only apply a promotion to a registered user. In the case of notices (for example), this is significant though.

    Similarly, the guest option doesn't make sense for promotions.
    Chris D likes this.
  18. Chris D

    Chris D XenForo Developer Staff Member

    Yep... I just checked the code in XenForo_Helper_Criteria... I'm pretty wrong :)

    All that criteria does is check if the user being awarded the trophy or promotion (or current visitor in the case of Notices) has a user ID... Absolutely everyone who runs through the criteria check in terms of Trophies and Promotions will definitely have a user ID. It does not actually verify if they are logged in or not.

    So as Mike says, it's completely meaningless in that context.

    Perfectly valid for use in Notices though. If the visitor has a user ID, they are logged in. If they don't, they are a guest.

    But my main point was, albeit incorrect about a possible solution for what you're wanting to do, is the criteria there can be used in theory by a multitude of different features in XenForo -- trophies, notices, promotions etc. They can even be plugged into very easily with add-ons (e.g. my Notifications add-on) and extended with new criteria. So, all things considered, it's absolutely not an unfinished feature. There's plenty of uses for that criteria.

    What you're wanting to do may need an add-on, or a rethink about what you're wanting to achieve.
  19. Weppa333

    Weppa333 Active Member


    Indeed I should have explained what I'm trying to do ; I'm in a post-migration (VB->XF) situation... I end up with a database with many "inactive" accounts. I would like to promote users registered since many years, but not to simply promote every old account. "Active old accounts only".

    So what I'm trying to do is to give promotions to old users if they connect to the board.

    It seemed to be what this checkbox is for (turn out to be a bit more complex than that), I'm not sure I follow every explanation here but I want to thank everyone for taking part in it - and try to help me. I really do appreciate.

    I actually don't need the promotion to take place the instant they connect, I simply need the promotion to act on users who actually did connect recently. What I'm actually looking for is an additional trigger "logged in in the past X days" but that does not exist (at least in 1.1) so I'm trying to find a workaround :)

    Having the cron run every minut is a quickfix ( again it's only temporary - after a few weeks of running every minut after migration, I can remove the promotions I've set up )

    but I'm open to better suggestions :)
  20. Chris D

    Chris D XenForo Developer Staff Member

    It's not complex at all. I made it a bit more confusing because I gave you some inaccurate information.

    It's as simple as this...

    With that checkbox enabled, the user being awarded the promotion would have to be a registered member of the board. So effectively in the context of promotions, it's pointless. Quite simply, it does not do what you want it to do.


    Yes... would have been useful for you to explain the reasoning earlier :)

    The criteria for promotions (and trophies) only runs for users who have been active on the board recently.

Share This Page