• Steve

    (@steveatty)


    I’ve got an options form set up using register_setting and settings_fields and its all working fine.

    But how do I put in a reset options button? Under the old way I added a button and checked for a $_POST value and could then erase and reset the settings I was storing.

    Using register_setting the $_POST gets intercepted and wiped before I can get to it and $_ACTION contains data but its the same data no matter which button I use.

Viewing 2 replies - 16 through 17 (of 17 total)
  • The array of values should be available inside the callback function, if you want to return nothing, then do that literally..

    return;

    ..as appose to returning the new array or a set of defaults..
    ie.

    return $defaults;

    or

    return $incoming_vars;

    When i’m refering to incoming vars, i mean the vars that get passed to the callback..

    function some_callback_name( $incoming_vars ) {

    Which is what you should be running over and sanitizing … not $_POST ..

    Any case, happy you were able to get to what you wanted… ??

    Thread Starter Steve

    (@steveatty)

    I know I don’t sanitize $_POST – its just that a submit button puts stuff into $_POST and that’s easier than having the user check a specific option to indicate they want to reset data and then save the settings.

    So I check the $_POST[‘submit’] variable (which tells me which button they’ve clicked on) and then I replace the relevant elements of the $options array with the default values and then return the array.

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘register_setting and re-setting option values.’ is closed to new replies.