2

I want to keep track of how long a specific WordPress theme has been active, not just installed. The end goal being I want to display a notice after a user has created x number of posts and the theme has been active for y hours.

I can handle displaying a notice, and counting the number of posts published in a specific time, but I was wondering if there is a good way to keep track of how many hours the theme has been active.

I imagine the best way would be to set an option or something stored in the database, and update this each hour? Or maybe save a timestamp in the database of when the theme was activated and when the theme was deactivated (initially 0 or null), then check these two variables and the current timestamp to determine how long its been active?

Thank you for any help you can offer!

  • Your last approach (saving the timestamps of de-/activation) sounds very promising and is how I would go for this. Have you tried it? Do you have specific questions about this? – kero Feb 8 '18 at 15:05
  • I have not tried it, I wanted to ask the community basically if they have done something like this, or if they had any specific methods that worked well, before I dive into it. I hope my question isn't too broad. – Jeremy Muckel Feb 8 '18 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.