1

Wordpress has similar functionality when another user is "taking over" editing a post WP gives you an instant warning.

I want to be able to either trigger a popup or show a new admin notice on top of the edit screen based on an option change. The main thing is that this has to be pretty much instantaneous or at a rate of the autosave - once a minute check or once every 30 seconds, whatever it is.

I googled it, tried using save_post hook. Have not had much luck with this yet.

I will highly appreciate any tips.

0

Bear in mind the web is a pull environment - not a push one. So whoever is making the data change can not push a notification to anyone else who might be surfing your website at the moment. Instead, it's every client's (browser) responsibility to call back to the server ever so often and see what's happened.

So conceptually, you'll need to install a javascript timer on the relevant pages (I assume only admin pages, and maybe not even all of them?).

That timer will use ajax to check back with the server every so often. (delay to be determined by you) The ajax call will need to keep track of when it last called the server (timestamp) and send that on every call, so your server can then determine what happened since the client last checked-in.

If the server finds something of interest, it can return a message, or data, to the client and the client's ajax handler can then display it as a popup.

In your case, it sounds like you'd want to look for posts that were updated since the last client call, presumably of a special post_type, and if you find one or more, then you have something to report about.

Hope this helps a bit!

  • Yes, thank you. I will put my own listener at least for the time being. Now that I read your reply and thought about it a bit more I doubt WP has a convenient hook that would let me hook into that stuff, after all most of it would be javascript, not php. – Jay Mar 17 '17 at 6:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.