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

XF 1.3 Usergroup Promotions not behaving

Mouth

Well-known member
#1
v1.3.0 RC2

I have 2 usergroup promotions that appear to be misbehaving ...

#1. Add user to usergroup 'validated' while user is member of usergroup 'paid' and not a member of usergroup 'validated'
#2. Add user to usergroup 'validated' while user is not a member of usergroup ('banned' or 'administrative') and user has 3 trophy point and user has been registered for 7 days

User 'fred' has 130 trophy points and been registered since 2010. He is not a member of usergroup 'banned' or 'administrative'. According to the above usergroup promotions, promotion #2 should promoted fred to be a member of usergroup 'validated'.
Fred is also a member of usergroup 'paid'. According to promotion #1 fred should be promoted to be a member of usergroup 'validated'.
.... thus, with either promotion, fred should be a member of the 'validated' usergroup

BUT, fred is NOT a member of usergroup 'validated' !

When I check the User Change Logs ( /admin.php?logs/user-change-log ) I see the following ...

Code:
Field Name             Old Value             New Value

14 minutes ago
Secondary User Groups             Paid Members, Validated Users               Paid Members

14 minutes ago
Secondary User Groups             Paid Members             Paid Members, Validated Users

Today at 13:20
Secondary User Groups             Paid Members, Validated Users             Paid Members

Today at 09:18
Secondary User Groups             Paid Members             Paid Members, Validated Users

Today at 08:13
Secondary User Groups             Paid Members, Validated Users             Paid Members

Today at 02:23
Secondary User Groups             Paid Members             Paid Members, Validated Users

Today at 01:15
Secondary User Groups             Paid Members, Validated Users             Paid Members

Today at 00:06
Secondary User Groups             Paid Members             Paid Members, Validated Users
Secondary User Groups             Paid Members             Paid Members, Validated Users

Yesterday at 12:41
Secondary User Groups             Paid Members, Validated Users             Paid Members
I cannot see why, when the usergroup promotions are being run, that the user is being removed from the 'validated' usergroup.

Do I have some flawed logic in my promotions?

I am also getting the following in my server error log, very much related it seems ...

Code:
Zend_Db_Statement_Mysqli_Exception: Mysqli prepare error: Operand should contain 1 column(s) - library/Zend/Db/Statement/Mysqli.php:77
Generated By: Unknown Account, 15 minutes ago
Stack Trace
#0 /var/www/netrider/library/Zend/Db/Statement.php(115): Zend_Db_Statement_Mysqli->_prepare('?????SELECT use...')
#1 /var/www/netrider/library/Zend/Db/Adapter/Mysqli.php(381): Zend_Db_Statement->__construct(Object(Zend_Db_Adapter_Mysqli), '?????SELECT use...')
#2 /var/www/netrider/library/Zend/Db/Adapter/Abstract.php(478): Zend_Db_Adapter_Mysqli->prepare('?????SELECT use...')
#3 /var/www/netrider/library/XenForo/Model.php(219): Zend_Db_Adapter_Abstract->query('?????SELECT use...', Array, 2)
#4 /var/www/netrider/library/XenForo/Model/User.php(327): XenForo_Model->fetchAllKeyed('?????SELECT use...', 'user_id')
#5 /var/www/netrider/library/XenForo/CronEntry/Trophy.php(32): XenForo_Model_User->getUsers(Array, Array)
#6 [internal function]: XenForo_CronEntry_Trophy::runTrophyCheck(Array)
#7 /var/www/netrider/library/XenForo/Model/Cron.php(356): call_user_func(Array, Array)
#8 /var/www/netrider/library/XenForo/Deferred/Cron.php(24): XenForo_Model_Cron->runEntry(Array)
#9 /var/www/netrider/library/XenForo/Model/Deferred.php(256): XenForo_Deferred_Cron->execute(Array, Array, 7.9999978542328, '')
#10 /var/www/netrider/library/XenForo/Model/Deferred.php(390): XenForo_Model_Deferred->runDeferred(Array, 7.9999978542328, '', false)
#11 /var/www/netrider/library/XenForo/Model/Deferred.php(335): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
#12 /var/www/netrider/deferred.php(23): XenForo_Model_Deferred->run(false)
#13 {main}
Request State
array(3) {
  ["url"] => string(35) "http://netrider.net.au/deferred.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(4) {
    ["_xfRequestUri"] => string(34) "/admin.php?users/fred.12345/edit"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
  }
}
 

Mike

XenForo developer
Staff member
#2
Fred is also a member of usergroup 'paid'. According to promotion #1 fred should be promoted to be a member of usergroup 'validated'.
This may be the cause, but I'm not positive -- based on what you laid out in #1, as soon as he gets the group "validated", he no longer meets the criteria for the promotion and thus should be removed. You shouldn't specify not having specific criteria that is added by the promotion. This would oscillate for every user that meets that criteria.

That said, if he meets #2 he should remain in the group. What does the promotion history show for this user?
 

Mouth

Well-known member
#4
This may be the cause, but I'm not positive -- based on what you laid out in #1, as soon as he gets the group "validated", he no longer meets the criteria for the promotion and thus should be removed. You shouldn't specify not having specific criteria that is added by the promotion. This would oscillate for every user that meets that criteria.
No sure how it would oscillate?
Execute - fred is a member of 'paid' and not a member of 'validate' - action is to make him a member of 'validate'
Next execute - fred is a member of 'paid' and is a member of 'validate' - skip, no action required.

I've removed the " not a member of 'validate' " for the apply while options, and see if the oscillation halts.
Will XF itself not action a " add to usergroup 'validated' " if the user is already a member? I guess I added that so it wouldn't do it unnecessarily. Sort of building the where clause of the SQL to skip if already a member.

That said, if he meets #2 he should remain in the group. What does the promotion history show for this user?
That's the user history in the first code block of my OP, for the example user 'fred'. Done by /admin.php?logs/user-change-log and the username filter in the top-right.
Starting at the bottom (labeled 12:41 yesterday) you can see he is a member of 'validated' and then removed, then the next run (labeled 00:06 today) he is not in 'validated' and added, and then the next run (labeled 01:15) he is removed from 'validated' once again.
.... and so on.
 

Mouth

Well-known member
#5
I had pretty similar issues a while back with members being thrown in and out of usergroups by promotions but I've since resolved that with a total permissions overhaul based on Brogans advice here:- http://xenforo.com/community/resources/implementing-permissions-across-multiple-user-groups.358/
Thanks. I'm comfortable I meet that guideline.
Registered is my baseline.
'Validated' (via usergroup promotion) with enhanced permissions (eg. edit sig, add showcase add-on items) after a brief delay period (help stop day 1 registration human spammers)
'Paid' for paying members via paypal upgrade with enhanced permissions (eg. access more nodes, higher qty inbox, etc.) . A usergroup promotion to ensure piad usergroup members are also members of 'validated'
 

Mike

XenForo developer
Staff member
#6
No sure how it would oscillate?
Execute - fred is a member of 'paid' and not a member of 'validate' - action is to make him a member of 'validate'
Next execute - fred is a member of 'paid' and is a member of 'validate' - skip, no action required.

I've removed the " not a member of 'validate' " for the apply while options, and see if the oscillation halts.
Will XF itself not action a " add to usergroup 'validated' " if the user is already a member? I guess I added that so it wouldn't do it unnecessarily. Sort of building the where clause of the SQL to skip if already a member.
A promotion cannot be applied twice. If a user has a promotion, the code will check against the criteria to confirm that they still meet it. Since the criteria has "not a member of X" but the user is a member of X, they won't meet the criteria.

That's the user history in the first code block of my OP, for the example user 'fred'. Done by /admin.php?logs/user-change-log and the username filter in the top-right.
I'm after the promotion history, not the user history. User group promotions > manage promoted users > search promotion history for "fred". Can you take a screenshot of what appears?
 

Rob

Well-known member
#7
This is almost identical to my use then.
I also use a validated group based on 5 posts but the principle is the same. Our paid members are added to the validated group also but not like this.
Can I suggest you make 'paid' members a member of the validated group at the time of purchase? Those who do not renew will fall back to unvalidated but your usergroup promotion will pick that up. It might make things a little easier for you.

Ie... once paid, add them to 'paid' AND 'validated' as part of the account upgrade.

Im a little confused why you dont want admins to also be in the validated group - that would make sense in a cascading permissions set up.
 

Mouth

Well-known member
#9
Ie... once paid, add them to 'paid' AND 'validated' as part of the account upgrade.
Had not considered that. Dohl! of course. Thanks :)

Im a little confused why you dont want admins to also be in the validated group - that would make sense in a cascading permissions set up.
I have an admin usergroup with usergroup permissions for allow(green) for everything, so seemed superfulous to also have them in validated
 

Mike

XenForo developer
Staff member
#10
Regarding the the second promotion, while I was looking at another error you reported, I looked at your promotion #2. It was set to not apply to premium members (someone who paid), so it wouldn't have matched for Fred (as expected). So really the issue mostly just came down to the oscillation from the promotion requiring the lack of a group that was added by the promotion.
 

Rob

Well-known member
#11
Had not considered that. Dohl! of course. Thanks :)

I have an admin usergroup with usergroup permissions for allow(green) for everything, so seemed superfulous to also have them in validated
I see. I use different levels of staff permissions but all staff regardless of importance belong to 'staff' I then build on those permissions with 2 other usergroups 'senior management' and 'admins'. I dont allow all admins access to everything going but if I did then I would most likely do what you are doing :)