0

I'm trying to get update_options to work with this function. Basically, the user enters an activation code and submits it through the plugin options page. The code is sent to the third party and the status returned if successful. This all works as it should but I can't get update_options to change the status of the option in question.

Here is the update function (part of an OOP framework I'm using):

  private function _admin_options_update() {
    // Verify submission for processing using wp_nonce
    if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
        $data = array();
        /**
         * Loop through each POSTed value and sanitize it to protect against malicious code. Please
         * note that rich text (or full HTML fields) should not be processed by this function and 
         * dealt with directly.
         */
        foreach( $_POST['data'] as $key => $val ) {
            $data[$key] = $this->_sanitize( $val );
        }

        /**
         * Place your options processing and storage code here
         */

        // Update the options value with the data submitted
        update_option( $this->option_name, $data );

        // Redirect back to the options page with the message flag to show the saved message
        wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
        exit;
    }
}

I'm trying to run this function:

update_option( $WPBackitup->options['status'], $license_data->license );

1 Answer 1

0

Figured this one out myself. Basically, the framework was sanitizing any data submitted via its form variables and then submitting it to the DB. I got the third party API to work by manually loading its return into the array that the framework sanitized and sent to the DB. Once I'd done that, update_options() worked like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.