• Knowledgebase
    • Knowledgebase
    • Snippets
    • Frequently asked questions
    • Roadmap
    • Facebook group
    • Customizations
  • Questions
    • Questions
    • My questions
  • Ask a question
  • Log In
  • Register
  • Notifications
  • Support us
Helpdesk
  • Knowledgebase
    • Knowledgebase
    • Snippets
    • Frequently asked questions
    • Roadmap
    • Facebook group
    • Customizations
  • Questions
    • Questions
    • My questions
  • Ask a question
  • Log In
  • Register
  • Notifications
  • Support us

Stats update after listing status change

Home/Stats update after listing status change/

Question stats

  • ActiveFebruary 9, 2019
  • Views88 times
  • Answers5 answers
88 viewsFebruary 9, 2019General
0
santirisco51 Posted February 6, 2019

Hi there, first of all congrats for the great work and the capabilities of your theme, its great.

Now the question: We need a way to allow the users “unpublish” their own listings when they want, we had built already the function and it’s working (user can change status from publish to draft if listing is publish and from draft to publish if is draft) but we have a bug in the stats update.

Here’s what we have done (everything under the child theme folder)

1- Create a function in functions.php to change post status and hook it in my-listings.php to show the button in “my-account/my-listings” cards, this button redirects to the dashboard to process the change.
2- Under my-listing-child/includes/extensions/stats/general.php we’ve added a new item ( $stats[’listings’][’draft’] ) to the array $stats[’listings’] under the function set_count_stats()
3- In the dashboard (my-listing-child/templates/dashboard/dashboard.php) we’ve added the query to change the post status before the line $stats = mylisting()->stats()->get_user_stats( get_current_user_id() );

We achieve the listing status change and this is visible in its card, however, the stats are not updated until we go to /my-listings and sometimes back to the dashboard. Actually seems pretty random when the stats are being updated, there’s not a pattern or at least we don’t see it, sometimes are updated after one reload, some others after two or even three

Any help will be appreciated

Best regards
Santi

Hassan Answered question February 9, 2019
Sorry, you do not have permission to read comments.

5 Answers

  • Active
  • Voted
  • Newest
  • Oldest
Register or Login
Question and answer is powered by AnsPress.io