• Resolved jlarysz

    (@jlarysz)


    I’m trying to user the settings API and failing. I’m using functions ‘register_settings’ and ‘add_settings_fields’ as documented. It all appears to work when I click ‘Save Changes’ button on my settings form but no settings are saved in table rs_options.

    I’ve traced it to function ‘update_option’ which sanitizes the value of my setting with a call to function ‘santize_option’. This sanitizes the value right down to NULL – clean, but useless.

    Why is it doing this, and how can I stop it with editing core code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • It’s doing it because you have an error in your code. Have a read of https://ottopress.com/2009/wordpress-settings-api-tutorial/ Perhaps that will help to highlight your code problem.

    Thread Starter jlarysz

    (@jlarysz)

    I figured it out just after posting this.

    I had a validation callback specified in add_settings_field function call, but the callback function was just a stub with no return value. By removing this callback the code automatically adds a bypass in function sanitize_option for the option name.

    It’s a little obscure and the huge volume of documentation and examples didn’t help – all I could do was walk the code.

    Thanks for getting back to me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Settings API wiping out values’ is closed to new replies.