*

Alej

  • **
  • 10 posts
user active ads problem
« on: February 18, 2025, 11:02:32 PM »
Hi everyone! there is a small error in the text under the username, where it says the number of active ads, as it is not updated. For example, I have a user with 4 ads, and one of them expires, the user renews it, but after that, instead of saying "4 active ads" it says "5 active ads". I don't understand what the problem is.
I checked the users table and verified that the number in the "i_items" field in the database is incorrect, as it says "5". I assumed it was a bug with the cron, so I disabled the automatic cron from osclass and set it up on my hosting with the command "wget ​​https://website.com/index.php?page=cron -O /dev/null" every minute, every hour, every day, every month, every weekday. Then I forced the expiration of an ad. Even when the ad expired the user's ad counter did not decrease, and when renewing the ad, the counter increased. I don't know what the problem could be.

*

MB Themes

Re: user active ads problem
« Reply #1 on: February 19, 2025, 10:14:48 PM »
Try to add this to your theme as example.

Code: [Select]
// Update user stats (items count, comments count)
function osc_update_user_statsX() {
  User::newinstance()->refreshNumItems();
  User::newinstance()->refreshNumComments();
}

osc_add_hook('cron_daily', 'osc_update_user_statsX');

Refresh functions should already be in User model.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Alej

  • **
  • 10 posts
Re: user active ads problem
« Reply #2 on: February 19, 2025, 10:57:22 PM »
I noticed that the active ads counter is updated, but not immediately after deleting an ad or after it expires, but the next day. Is there a way to make it update instantly?

*

MB Themes

Re: user active ads problem
« Reply #3 on: Yesterday at 02:48:47 PM »
It should do immediately, but there is million reason why it may not do it right at the moment.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Alej

  • **
  • 10 posts
Re: user active ads problem
« Reply #4 on: Yesterday at 05:06:00 PM »
Is the cron configured correctly as I detailed?

*

MB Themes

Re: user active ads problem
« Reply #5 on: Yesterday at 06:05:14 PM »
Cron setup details are in docs
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots