- Views88 times
- Answers5 answers
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