I have an admin options page which works great. I got a submenu page for banner upload and I need to add one more field. The problem is.. when I press Submit, the changes made in that field wont save, but the image does. I don’t know how to insert my new fields into the validate function.
Here is my validate function:

function wezo_options_validate( $input ) {
    $default_options = wezo_get_default_options();
    $valid_input = $default_options;
    $wezo_options = get_option('theme_wezo_options');
    $submit = ! empty($input['submit']) ? true : false;
    $reset = ! empty($input['reset']) ? true : false;
    $delete_banner = ! empty($input['delete_banner']) ? true : false;
    if ( $submit ) {
        if ( $wezo_options['banner'] != $input['banner']  && $wezo_options['banner'] != '' )
            delete_image2( $wezo_options['banner'] );
        $valid_input['banner'] = $input['banner'];
    }
    elseif ( $reset ) {
        delete_image2( $wezo_options['banner'] );
        $valid_input['banner'] = $default_options['banner'];
    }
    elseif ( $delete_banner ) {
        delete_image2( $wezo_options['banner'] );
        $valid_input['banner'] = '';
    }
    return $valid_input;
}

And here is the new field’s function (ex. checkbox):

function checkbox_setting2() {
    $wezo_options = get_option( 'theme_wezo_options' );
    $html = '<input type="checkbox" id="checkbox2" name="theme_wezo_options[checkbox2]" value="1"' . checked( 1, $wezo_options['checkbox2'], false ) . '/>';
    $html .= '<label for="checkbox_example">This is an example of a checkbox2</label>';
    echo $html;
}

This function works on other menu pages which does not include the upload image function.

Thanks!

Read more here: Not saving the new field when submit (PHP WordPress)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: