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 );
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 );
You can use this function: get_blog_option https://codex.wordpress.org/Function_Reference/get_blog_option Use get_sites function to retrieve blogs ID from your site.
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
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
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
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.
You could use a JavaScript alert to do what you’re asking, but the only way I can think of doing it would likely be a fair chunk of unnecessary added complexity. I’ve written a small PHP script using the code from your example. If you have any difficulty amending it for your purposes, please don’t … Read more
If you look at do_settings_fields() (line 1125, /wp-admin/includes/template.php), you can see that the table information is hardcoded into the the settings API. If you wish to not use the table, you will need to develop your own settings functions.
You’re absolutely right that you can pass reusable form field markup to add_settings_field(). The trick is to define the data type for each setting, and then pass the same callback to each call to add_settings_field(). Within that callback, you simply add a switch that includes cases for each data type. Here’s how I do it … Read more
I’ve answered a similar Question. Basically: create a Dropin plugin at the root of wp-content named install.php inside install.php, create a new version of the pluggable function wp_install_defaults() remove all unwanted defaults and customize at will, like: update_option(‘template’, ‘your-theme’); update_option(‘stylesheet’, ‘your-theme’); update_option(‘current_theme’, ‘Your Theme’); update_option(‘my_theme_options’, $theme_options_array ); auto-activate some bundled plugins bundle everything into one … Read more