0

After activating my plugin I should go to settings -> permalinks and click on the Save button to make custom endpoints ( for my-account page ) work. How can I do it programmatically? ( I used flush_rewrite_rules but it didn't work. )

3
  • Where/when did you call flush_rewrite_rules? Keep in mind that this function shouldn't be called on every page load as it changes the database, can you include the code you used to try this?
    – Tom J Nowell
    Commented Sep 14, 2020 at 14:39
  • The problem was not flush_rewrite_rules . Problem caused from : Instead of adding custom endpoint one time on activation, i was doing it everytime. So one time flush_rewrite_rules could not handle it.
    – amiwebdev
    Commented Sep 24, 2020 at 7:11
  • can you post your solution as an answer along with the change you made in code? Comments can't be marked as the correct answer or upvoted for points
    – Tom J Nowell
    Commented Sep 24, 2020 at 10:01

1 Answer 1

0

flush_rewrite_rules should only be called on the plugin activation OR after you update or add rewrite rules programatically.

If it does not work after verifying this, there is some other issue on your site. Make sure you are not calling flush_rewrite_rules in constructor or somewhere else on every page load.

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.