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

User Group Promotions Only Run Once?

Discussion in 'XenForo Questions and Support' started by AdamCapriola, May 6, 2012.

  1. AdamCapriola

    AdamCapriola Member

    I'm in the process of moving my site from vB to XenForo, and have to admit I'm pretty stoked about making the move!

    One thing I noticed while I'm testing settings is that if a user receives a promotion, it seems to only run once. Here's an example of what I mean:

    I set up a promotion where if a user is a member of User Group A, then they should also be added to User Group B. I manually ran the cron job to make sure this works, and it does beautifully.

    However let's say the user loses membership to User Groups A and B, and then becomes a member of User Group C. If that member regains their membership in User Group A at a later date, the promotion won't add them to User Group B again as well unless you delete the record from the user's Promotion History.

    Is there any way to make sure users are ALWAYS promoted when the meet the promotion requirements, even if they've lost the promotion at one point or the other? Or is this the way it's meant to be? Or am I doing something wrong?

    Thanks in advance for any help!

    P.S. I see on this page it says:
    I guess that's my problem, sorta. I won't be using the official function to "demote" users, but I have member management software (aMember) that controls users' user groups. So they might be switched from User Group A to C, and back to A, depending whether they purchase a premium membership.

    This normally wouldn't be a problem, but aMember integration at this point only can assign a user to 1 user group at a time. I thought I could circumvent the issue with promotions to allow users to be automatically assigned secondary user groups.

    Is there a way to make this work?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Run these queries to wipe the promotion logs. In the second query you need to specify the id of group B:

    Code:
    TRUNCATE TABLE xf_user_group_promotion_log;
    
    DELETE
    FROM xf_user_group_change
    WHERE group_ids = '93';
    
    That should force everyone to be processed again for that promotion. That should fix your problem.

    Note that the cron only updates users who have been active in the last 72 hours, so there may be a delay for some users despite manually running the cron.

    Admin CP -> Tools -> Cron Entries -> User Group Promotions -> Controls: Run
     
    Chris D likes this.
  3. AdamCapriola

    AdamCapriola Member

    Thanks Jake! Is this something I would need to run just once?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You would have to run these queries whenever you wanted to re-promote a user that had already received the promotion previously.
     
  5. AdamCapriola

    AdamCapriola Member

    Ok, gotcha. My problem is that I'm going to have users automatically going in and out of user groups daily, so I need a solution that'll let the promotions run, regardless if the user was promoted previously. It would be impossible for me to manually keep clearing everything.

    Is there maybe a way to prevent XenForo from logging Promotion History? It seems like either doing that, or creating some rule that says to ignore Promotion History when adding promotions would do the trick.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That's possible with an addon or code modification. These are the relevant classes:

    XenForo_CronEntry_UserGroupPromotion
    XenForo_Model_UserGroupPromotion


    This obviously requires programming ability. If you would like some one to write this for you then you can post a request:

    http://xenforo.com/community/forums/resource-and-add-on-requests.68/
     
    AdamCapriola likes this.
  7. LDW

    LDW Member

    jake if I run this will it just reset all users? It wont move anyone out of the user group they are in?
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Correct. Those queries will not actually remove users from that group. It will just remove the record of the group change which will allow users to be added to that group again via a future promotion, whereas normally users are only allowed to be added once such that re-promoting doesn't work.

    Note that if you are doing this for user upgrades then you also need to remove the appropriate record(s) from xf_user_upgrade_active to allow users to repurchase an upgrade without a prior record. You can prune the table but this may not be appropriate if you don't wish to remove all current upgrades.

    Code:
    TRUNCATE TABLE xf_user_upgrade_active;
    
    Doing this with upgrades requires more consideration than with promotions because you are dealing with money payments and durations unlike promotions.
     

Share This Page