How to validate register settings array

Personally I’d do it the same way, since it seems to be the only point where you can examine user input and validate it. Also, heavily borrowing from code sample in this excellent article: function wpPartValidate_settings( $input ) { if ( check_admin_referer( ‘wpPart_nonce_field’, ‘wpPart_nonce_verify_adm’ ) ) { // Create our array for storing the validated … Read more

Is it safe to post form data via Ajax to the settings api? Am I missing something?

WordPress does not natively use Ajax submits with Settings API, so there isn’t really best practice for it. I remember scbFramework having such option, but it was removed. Essentially there is nothing inherently more insecure to such submit, you should treat form data as untrusted regardless of submit method and appropriately sanitize and validate it … Read more

Generating User(s) with Settings API

You are using add_settings_field wrong: the function sl_wp_create_user is being passed as $args (and you probably don’t need any args), and it should be the sanitize callback for register_settings. Make the input like: function sl_render_users_input() { echo ‘<input id=”num_users[value]” name=”num_users[value]” type=”input” value=”” />’; } And the sanitize function: function sl_wp_create_user( $input ) { if( isset( … Read more

Custom theme options Radio inputs not saving

Why isn’t the following option getting saved? Because the database option name (the second parameter for register_setting()) is aa_myoption, hence the input name has to be aa_myoption or in the array notation like aa_myoption[my_field]: <input name=”aa_myoption”> <!– like this –> <input name=”aa_myoption[my_field]”> <!– or this –> Secondly, when you retrieve the option value and when … Read more

Settings API get_option best practices

Is there a better, more efficient way – considered a “best practice” – to approach this? Yes! Storing structured data in a single option is bad practice. You should use the option name to seperate your data. Otherwise by using arrays and objects, WordPress cannot store those in the database, so it has to turn … Read more

Settings Page won’t save

For anyone else that may not have read the above comments and are having a possibly similar issue, @epilektric has answered the question stating that the = sign was missing after the value attribute under the field_1 and field_2 functions.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)