I'm using the Settings API to create options for plugin. Do I need to validate the input values for the security (for example stripslashes etc)? (I could not find that part in most of the tutorials). Here's what I'm doing:

<form method="post" action="options.php">
        settings_fields( 'sandbox_theme_display_options' );
        do_settings_sections( 'sandbox_theme_display_options' );

function sandbox_initialize_theme_options() {
        __( 'Display Options', 'sandbox' ),

        __( 'Header', 'sandbox' ),
            __( 'Activate this setting to display the header.', 'sandbox' ),


add_action( 'admin_init', 'sandbox_initialize_theme_options' );

1 Answer 1


No, you don't need to validate/clean/escape because of security flaws in wordpress. Wordpress use prepared statements by default.

However, you can validate by yourself that the content is what you expecting. For example if you only want numbers you can use is_numeric() or is_float(). Or match the input value to an array of predefined strings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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