• I have a plugin which adds a number of WP settings pages, where the user will enter various values and then need to hit the save button at the bottom. This is all driven by the standard WP functions add_settings_section, add_settings_field, register_setting, settings_fields, do_settings_sections etc.

    I’d like to prevent users from accidentally leaving a settings page without saving changes they’ve made. Two common strategies spring to mind, 1) track a ‘dirty’ flag after a form field is changed and pop up a dialog if they attempt to leave whence set, 2) AJAX functionality to implicitly save in the background after every form field is updated.

    Both would address the problem, but the former could annoy users with a popup, the latter prevents you from deliberately leaving the page and not saving changes you don’t want.

    My questions:
    Is there any mechanisms/functionality within WordPress I could leverage here?
    Which approach is most favoured and most consistent with other WP use cases?

    Thanks!

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

The topic ‘Warn visitors leaving a plugin setting page without saving?’ is closed to new replies.