0

I am working on a plugin that registers custom new endpoints in every update and we need to Flush Rewrite Rules after every update of the plugin.

Flushing Rewrite Rules are easy after activation of the plugin and there is a lot of tutorials out there about this

But in the case of Flushing Rewrite Rules after Update I can't find any solution

2
  • 1
    you can save the plugin version in an option and when the version change, you flush the cache.
    – Kaperto
    Dec 23, 2019 at 9:23
  • thank you your comment was the answer
    – mir.moezi
    Dec 30, 2019 at 5:06

2 Answers 2

2

Your answer above was close but is should be

add_action( 'upgrader_process_complete', 'wp_answ_355114' );

not

do_action( 'upgrader_process_complete', 'wp_answ_355114' );

noting that this is only the case when a plugin is updated view WP plugin updates.

0

I haven't verified this but you could try the upgrader_process_complete hook. More information on that hook.

like follows

function wp_answ_355114() {

flush_rewrite_rules(); 

}

do_action( 'upgrader_process_complete', 'wp_answ_355114' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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