Title: Clear Cache with Php Command?
Last modified: December 8, 2019

---

# Clear Cache with Php Command?

 *  [JohnChandlerEdmonton](https://wordpress.org/support/users/johnchandleredmonton/)
 * (@johnchandleredmonton)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-with-php-command/)
 * What is the correct way to cause a wordpress widget to display the most up-to-
   date info? I am guessing that when the info changes the cache muse be cleared.
 * Here is an example of what I mean.
 * I have a wordpress widget that displays Hello <first name> <lastname>. It appears
   on every page. If the user edits their name, the widget still displays the old
   name until the breeze cache is cleared. (except if the user is an admin, then
   it seems this problem does not occur).
 * If I hook in this command into the routine that processes a user name change
   
   breeze_clean_cache(); the function is not found and the php script dies.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [adeelkhan](https://wordpress.org/support/users/adeelkhan/)
 * (@adeelkhan)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-with-php-command/#post-12219544)
 * Hi
 * could you please confirm that the user changes its name information from admin
   OR front end of the site using the widget?
 * While update post/page or any widget area from admin. Breeze clears its cache
   and change will reflect on site.
 *  Thread Starter [JohnChandlerEdmonton](https://wordpress.org/support/users/johnchandleredmonton/)
 * (@johnchandleredmonton)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-with-php-command/#post-12220207)
 * Yes the user edits his name from the front end.
 * function my_woocommerce_save_account_details($user_id) {
    $fn = $_POST[‘account_first_name’];
   $ln = $_POST[‘account_last_name’]; $display_name = trim(trim($fn) . ‘ ‘ . trim(
   $ln)); $x = wp_update_user( array( ‘ID’ => $user_id, ‘display_name’ => sanitize_text_field(
   remove_accents($display_name)) ) ); } add_action( ‘woocommerce_save_account_details’,‘
   my_woocommerce_save_account_details’, 10, 1 );
 * Then when the user visits a page (that has already been cached) it will not show
   the new display name in a widget in the sidebar of every page.
 * I guess I need to put in a command into my code like
    breeze_clean_cache();
 * Or alternatively I could do an “insert_post” and then “delete_post” to cause 
   the cache to be cleared.
 * Let me know what you would recommend.
 * Thanks!
 *  Thread Starter [JohnChandlerEdmonton](https://wordpress.org/support/users/johnchandleredmonton/)
 * (@johnchandleredmonton)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-with-php-command/#post-12232548)
 * P.S. I tried adding this into my name-update code (shown above). It did not force
   the cache to be cleared.
 *  // Create post object
    $my_post = array(); $my_post[‘post_title’] = ‘Temp post’;
   $my_post[‘post_content’] = ‘This is a temp post made to force the cache to clear.’;
   $my_post[‘post_status’] = ‘publish’; $my_post[‘post_author’] = 1; $my_post[‘post_category’]
   = array(0); $id = wp_insert_post( $my_post ); wp_delete_post($id);
 * Surely there must be a simple command you can give me that will do this?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Clear Cache with Php Command?’ is closed to new replies.

 * ![](https://ps.w.org/breeze/assets/icon-256x256.gif?rev=3352595)
 * [Breeze Cache](https://wordpress.org/plugins/breeze/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/breeze/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/breeze/)
 * [Active Topics](https://wordpress.org/support/plugin/breeze/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/breeze/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/breeze/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [JohnChandlerEdmonton](https://wordpress.org/support/users/johnchandleredmonton/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-with-php-command/#post-12232548)
 * Status: not resolved