Can you refresh ONLY the wordpress adminbar and not the whole page?


Here is my challenge:

I have included an electronic wallet in the admin bar of my wordpress site and what I need to do is to refresh ONLY the admin bar so that, upon a purchase, the electronic wallet is updated and reflects the new total from the database with the purchase amount subtracted from it without having to refresh the whole page.

I mainly do this to avoid excessive bandwidth usage and the reinitializing of certain plugins I have on the site such as an mp3 player.

Does anyone have any ideas? Been trying to write a function for it and call that function when the database is being updated but I haven’t been able to figure it out, (pretty new at this).


Ok. Sterling Hamilton answer was definitely helpful but I need a bit more. I tried to implement the Javascript to refresh every 10 seconds and it works beautifully but the information being refreshed needs the function get_current_user_info(); to be called so the text in the tag can reflect the new data in the database.

You see, on the webpage I have an electronic wallet where people click and buy things. On clicking, the database is updated but the electronic wallet, which I have in the wp_admin_bar needs to be refreshed as well in order to reflect the database changes. As far as I understand, this requires that I re-call the function get_current_user_info(); and have the text in the refresh and show the actual amount in the e-wallet.

I have looked into all the action hooks available but none serve the purpose of refreshing every 30 seconds, let’s say, so I haven’t been able to make a plugin or hard code the php. Does anyone have any suggestions???

Arion 8 months 2020-11-24T08:10:37-05:00 0 Answers 12 views 0

Leave an answer