register_setting() vs add_option()

So do I still need to hook admin_init and call those register_setting() if I did add_option() before? Yes. You need. You may add add_option to set the default value. Another call to add_option will do nothing. However, the idea of register_setting() is more than just add_option(). Each setting has the context page such as (general, … Read more

How can I get all user options?

You will get all the meta for the user by using get_user_meta function $all_meta_for_user = get_user_meta( [user ID] ); echo “<pre>”; print_r( $all_meta_for_user );

Submenu pages delete settings from options array when saved

Yep you are missing something, On your validate_options function you need to: get an array of all existing options. update only the options your Submenu page handles. return that array. So something like: function validate_options($input){ //do regular validation stuff //… //… //get all options $options = get_option(THEMENAME . ‘_settings’); //update only the neede options foreach … Read more

Fallback when Transient API fails

Mark Jaquith made a “TLC Transients” method that you might find useful. Essentially, it implements a transient interface that does soft expiration and background updating. https://github.com/markjaquith/WP-TLC-Transients The idea is that you define a function to do the call that gets the data, then define the transient and pass it that function as a callback. When … Read more

Set WordPress settings programmatically

I am satisfied with Nikolay Yordanov’s answer. Just generalizing the solution. Yes, we can update WordPress options programmatically. WordPress saves options in wp_options table. wp_options holds two rows option_name and option_value to store key and value respectively. We need right option_name and a way to save value in wp_options table. As we know, we can … Read more

Efficient way of saving plugin options

Store the options in a single array and write your plugin as a class. Load the options in the constructor and save it as a member variable and you’ll have access to it everywhere in the plugin.

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