Update problem with update_option() in combination with register_setting()

Note what happens when you provide sanitize callback in register_setting(). It register a filter to sanitize your options add_filter( “sanitize_option_{$option_name}”, $sanitize_callback ); Now when you do update_option() then trigger your own function to prevent saving 😀 Because update_option() calls $value = sanitize_option( $option, $value ); Solution: Remove register_settings() callback before you call update_option(). function gtp_remove_installing_data() … Read more

Prevent invalid or empty values from being saved to the database and retain the form field values upon error

You’d do it something like this: function sanitize_number_callback ($input){ if( !preg_match( ‘/…regex for valid here…/’, $input ) ){ add_settings_error( ‘my_option’, esc_attr( ‘my_option’ ), //becomes part of id attribute of error message __( ‘Number must be a positive integer’, ‘wordpress’ ), //default text zone ‘error’ ); $input = get_option( ‘my_option’ ); //keep old value } return … Read more

Pulling Data from CSV vs. pulling data from database

Reading, searching and closing a file every time the page is loaded is highly time consuming. Database systems are highly optimized for reading and writing huge amount of records, querying data, providing schemes, relations between the data etc. What will happen if 10K users hit the taxonomy page? How you will handle the updates of … Read more

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