Open
Labels
Milestone
Description
Currently, clicking the Generate verification codes button will generate codes and save them to usermeta. I think most users will only expect the codes to be saved if they click the Update Profile button.
If they navigate away from the page without clicking that, they'll assume nothing has changed, but in reality it has. This can be a problem if they already had existing codes, and accidentally clicked the button, or clicked it intentionally but then decided they didn't want new codes. Their old codes are now invalid, but they don't know that and won't save the new ones. They could be locked out in the future because their saved codes no longer work.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
jeffpaul commentedon Jan 25, 2023
Alternatively, I might suggest we change the button to
Generate verification codes and save to profile(or some better worded text) as (1) that seems like a better state to get users to, (2) I don't expect (m)any people want to just generate codes and not make them what relates to their user account, (3) its possible folks would click aGenerate verification codesbutton and not realize they need to clickUpdate Profileto save those codes to their profile.iandunn commentedon Jan 26, 2023
That (or some text near the button) could be a good alternative 👍🏻 The most important thing is that the user is informed about what will happen.
I was thinking of situations where the user accidentally clicks the button, or when they click it and then want to "undo" that by leaving the page without saving. That could be the case if someone is running low on codes and decides to regenerate, but then discovers their printer isn't working or something, so they want to come back and do it later.
Those are admittedly edge cases, though.
That's a fair point, especially since the current precedent is that you don't need to. Not having to click
Updateis inconsistent with the rest of the setting on that page, though, and some of the Two Factor settings. IMO it'd best for UX if everything is consistent.This isn't something I feel strongly about, though, it's an edge case and I can see your point of view 👍🏻
pkevan commentedon Jan 27, 2023
Perhaps some kind of confirmation dialogue would help with the accidental (or intentional) click, and draw their attention to the fact that codes will be updated?
dd32 commentedon Feb 10, 2023
This could be dealt with the same as the TOTP setup process.
Rather than generating and saving them server-side before showing the UI, they could be generated, provided to the client, and only hashed/saved server-side upon a second API request after user action. If we need to validate that the server generated the codes (to prevent someone sending bad-random codes?) a signature could be included if required..
That wouldn't prevent the UI being changed to "Generate and save" though.
timiwahalahti commentedon Feb 22, 2023
A better procedure is needed indeed. Locked my .org account yesterday, as I didn't expect visiting the backup codes page also to trigger those to be activated. Especially since I didn't manage to set up any TOTP a few moments earlier (because of now fixed bug).
Is there a reason why backup codes should even be generated if 2FA is not activated?
masteradhoc commentedon Feb 22, 2026
Hey @dd32 @iandunn
I noticed this issue has already been resolved in the wp.org version of Two‑Factor. Would you be open to bringing that fix back into this plugin as well?
I tested the wp.org version and it works great. It would be awesome to streamline things so the behavior is consistent here too. 🙂
dd32 commentedon Feb 22, 2026
@masteradhoc The WordPress.org version has the same issue at present, AFAIK, it's just the custom UI is attempting to force the user to save them and stores a value that the user confirmed they saved them.
Unfortunately many users still do not save the recovery tokens.
Note: The wp.org custom UI and two-factor customizations is here: https://github.com/wordpress/wporg-two-factor All of the code can be pulled back to two-factor without concern if so desired.