Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#19315 closed defect (bug) (worksforme)

sanitize_option callback in register_setting()

Reported by: digitalnature's profile digitalnature Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2
Component: Validation Keywords:
Focuses: 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)

#1 @sirzooro
12 years ago

Try to return old value from sanitization callback instead of calling update_option() in it - should be enough.

#2 in reply to: ↑ description @nacin
12 years 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.

Note: See TracTickets for help on using tickets.