[TH] User Criteria Extended

[TH] User Criteria Extended 1.0.6

No permission to download
We added a criteria based on the user's age and it doesn't seem to be working. Nobody is getting promoted to the selected usergroup. What are the troubleshooting steps here?

1585863069431.webp
1585863091317.webp
 
User group promotions are usually only applied when the user has been online within the last couple of hours (2 iirc). A better way to test if it's the criteria being not working as expected or them just not being active would be to grab a test account and set up a notification that targets only those criteria.
 
Yes, I forgot to mention - We did set up a notice that targets that criteria, made a new user with a date of birth 75 years in the past, that user doesn't see the notice. We've got several hundred members online right now, most of them older than 55. The promotion cron job ought to be adding most of them to the usergroup.
 
Yes, I forgot to mention - We did set up a notice that targets that criteria, made a new user with a date of birth 75 years in the past, that user doesn't see the notice. We've got several hundred members online right now, most of them older than 55. The promotion cron job ought to be adding most of them to the usergroup.
I'll get that checked out on our next round of updates then, thanks for reporting!
 
I am ready to buy this add-on when you make it paid. I would like updates to come faster. This plugin is very important to us. Make a fee if necessary. I am ready to pay. Please get faster updates.
Much appreciated. No worries though, the add-on is staying free for everyone, we don't want to press out profit of it just because people rely on it. I'm planning to get around to update it next week.

If anyone wants to help out, feel free to list all criteria you feel aren't working and I'll make sure to test/debug them specifically.
 
Much appreciated. No worries though, the add-on is staying free for everyone, we don't want to press out profit of it just because people rely on it. I'm planning to get around to update it next week.

If anyone wants to help out, feel free to list all criteria you feel aren't working and I'll make sure to test/debug them specifically.
Could u make like attachment restriction as in x attachment download in specific category/forum for x person in a day or week or something? Wpuld be nice to have it :) thanks.
 
Could u make like attachment restriction as in x attachment download in specific category/forum for x person in a day or week or something? Wpuld be nice to have it :) thanks.
That's not being tracked by XenForo unfortunately, so not a criteria I could build without implementing additional tracking, which is deliberately not done in the add-on so far.
 
ThemeHouse updated [TH] User Criteria Extended with a new update entry:

Version 1.0.5 Patch Level 1 released!

Changes:
  • Fixed criteria not returning value:
    • User has posted [no more than / at least] X posts in the last Y days
    • User has [no more than / at least] X posts in [one / all combined / each] of the selected forums
    • User has posted [no more than / at least] X posts in the last Y days in the selected nodes
    • User has not been active in the last X days
  • Fixed criteria not matching on exact match:
    • User has no more than X bookmarks
    • User has at...

Read the rest of this update entry...
 
Thanks for the update, though it seems like there are still issues. We have a promotion set up, and its only criteria is that the users be at least 55 years old. We activated it today after the upgrade, and users are being promoted despite being less than 55 years old.
 
Thanks for the update, though it seems like there are still issues. We have a promotion set up, and its only criteria is that the users be at least 55 years old. We activated it today after the upgrade, and users are being promoted despite being less than 55 years old.

Oh yeah, had a short look and it seems the code for those two is doing some absolute quirky check that just happened to evaluate to the right thing in my test cases. :cautious: Patch incoming.
 
Thanks for the update. Seems to be working now, I think.

Though looks like there might need to be some error checking added somewhere. I haven't dug too far in. Server error log is FILLED with notices from Carbon now.

Code:
ErrorException: [E_NOTICE] Object of class DateTime could not be converted to int src/addons/ThemeHouse/UserCriteria/vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php:30

#0 src/addons/ThemeHouse/UserCriteria/vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php(30): XF::handlePhpError(8, '[E_NOTICE] Obje...', '/home/badgerand...', 30, Array)
#1 src/addons/ThemeHouse/UserCriteria/Listener/CriteriaUser.php(1417): Carbon\Carbon::createFromTimestamp(Object(DateTime))
#2 [internal function]: ThemeHouse\UserCriteria\Listener\CriteriaUser::criteriaUser('th_age', Array, Object(SV\ConversationEssentials\XF\Entity\User), false)
#3 src/XF/Extension.php(67): call_user_func_array(Array, Array)
#4 src/XF/App.php(2654): XF\Extension->fire('criteria_user', Array, NULL)
#5 src/XF/Criteria/User.php(64): XF\App->fire('criteria_user', Array)
#6 src/XF/Criteria/AbstractCriteria.php(63): XF\Criteria\User->isUnknownMatched('th_age', Array, Object(SV\ConversationEssentials\XF\Entity\User))
#7 src/XF/Repository/UserGroupPromotion.php(112): XF\Criteria\AbstractCriteria->isMatched(Object(SV\ConversationEssentials\XF\Entity\User))
#8 src/XF/Pub/App.php(236): XF\Repository\UserGroupPromotion->updatePromotionsForUser(Object(SV\ConversationEssentials\XF\Entity\User))
#9 src/XF/Pub/App.php(189): XF\Pub\App->updateUserCaches()
#10 src/XF/App.php(2180): XF\Pub\App->start(true)
#11 src/XF.php(391): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}

Also

Code:
#0 src/addons/ThemeHouse/UserCriteria/Listener/CriteriaUser.php(1416): XF::handlePhpError(8, '[E_NOTICE] Unde...', '/home/badgerand...', 1416, Array)
#1 [internal function]: ThemeHouse\UserCriteria\Listener\CriteriaUser::criteriaUser('th_age', Array, Object(SV\ConversationEssentials\XF\Entity\User), false)
#2 src/XF/Extension.php(67): call_user_func_array(Array, Array)
#3 src/XF/App.php(2654): XF\Extension->fire('criteria_user', Array, NULL)
#4 src/XF/Criteria/User.php(64): XF\App->fire('criteria_user', Array)
#5 src/XF/Criteria/AbstractCriteria.php(63): XF\Criteria\User->isUnknownMatched('th_age', Array, Object(SV\ConversationEssentials\XF\Entity\User))
#6 src/XF/NoticeList.php(93): XF\Criteria\AbstractCriteria->isMatched(Object(SV\ConversationEssentials\XF\Entity\User))
#7 src/XF/Pub/App.php(594): XF\NoticeList->addConditionalNotice(11, 'block', 'Test. Ignore', Array)
#8 src/XF/Pub/App.php(531): XF\Pub\App->getNoticeList(Array)
#9 src/XF/App.php(1995): XF\Pub\App->renderPageHtml('








    
    
    
...', Array, Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#10 src/XF/Mvc/Dispatcher.php(402): XF\App->renderPage('








    
    
    
...', Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#11 src/XF/Mvc/Dispatcher.php(58): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#12 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#13 src/XF.php(391): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}
 
There's definitely still something very odd going on. We have a promotion set up that ONLY promotes based on the user's age. Users should be at least 55 years old to be promoted. When the promotion is active, we get all kinds of users promoted, most of whom (If not all) are NOT over 55 years of age.

I took a peek at the code, and the conditional doesn't make a ton of sense.

PHP:
if ($birthday->diffInYears() >= $user->Profile->age) {
                        $returnValue = true;
                    }

You're getting the birthday, then getting the diff in years from today, then comparing that diff to..the user's age. The two will always be equal though, right? So the conditional will always return true.
 
There's definitely still something very odd going on. We have a promotion set up that ONLY promotes based on the user's age. Users should be at least 55 years old to be promoted. When the promotion is active, we get all kinds of users promoted, most of whom (If not all) are NOT over 55 years of age.

I took a peek at the code, and the conditional doesn't make a ton of sense.

PHP:
if ($birthday->diffInYears() >= $user->Profile->age) {
                        $returnValue = true;
                    }

You're getting the birthday, then getting the diff in years from today, then comparing that diff to..the user's age. The two will always be equal though, right? So the conditional will always return true.
You running patch level 2? That's the conditional that has been fixed with the last release.
 
Yes, we upgraded today hoping that it would fix it, and it does not. Unless I'm misreading that code, you're comparing the user's calculated age (Based on their birthdate) to their age. So they'll always be equal. Instead, you should be comparing the user's age to whatever number we put into the Criteria field.
 
I'll get it checked out on Wednesday. That doesn't appear to be the latest code, but maybe the packaging went wrong somewhere.
 
Thanks. FWIW, I just downloaded a fresh copy, this code is what's present.

Originally, the user criteria didn't promote anyone. Now with the update, it promotes everyone. We need something in the middle of those two things ;) LOL

Really appreciate this resource. It adds a ton of valuable features.
 
Top Bottom