Opened 19 months ago
Closed 9 months ago
#19315 closed defect (bug) (worksforme)
sanitize_option callback in register_setting()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Validation | Version: | 3.2 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
This is the user validation function you pass to register setting.
The problem is that if you're manually updating your option within this function, your option won't get updated because update_option() will run your callback on $newvalue, which changes it to the old option value. So it will do nothing because it would appear that both new and old values are identical.
I know there aren't many situations in which you would want to modify your option within that validation callback because that's what that callback should do in the first place, but they do exist :)
Change History (2)
comment:2
in reply to:
↑ description
nacin
— 9 months ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Replying to digitalnature:
I know there aren't many situations in which you would want to modify your option within that validation callback because that's what that callback should do in the first place, but they do exist :)
I don't think they do. Feel free to reopen this with an example, though.
Try to return old value from sanitization callback instead of calling update_option() in it - should be enough.