Plugin options not appearing on options page using tabbed navigation
I figured out the problem. I was referencing the wrong page ID in my add_settings_section() call.
I figured out the problem. I was referencing the wrong page ID in my add_settings_section() call.
Change the [user] to [users][]. Hope that will fix the problem. Now you’ll get all the value in associative array within [users][‘your-checkbox-data-array’] So your code will be like- <?php $WPusers = get_users( ‘orderby=nicename&role=administrator’ ); foreach ( $WPusers as $user ) { ?> <input type=”checkbox” name=”<?php echo $this->plugin_name; ?>[users][]” id=”<?php echo $this->plugin_name; ?>-users” value=”<?php echo $user->ID; … Read more
You need to add a ‘selected’ value to the option output, so that the html displays the value that’s saved in the psg_settings. Something like this: function psg_dyn_select_1_render ( ) { $options = get_option( ‘psg_settings’ ); $files = glob( plugin_dir_path( __FILE__ ) . “assets/images/*” ); ?> <select name=”psg_settings[psg_dyn_select_1]”> <?php foreach ($files as $filename){ $filename = … Read more
How to store multiple instances of the plugin’s options for various shortcodes
I echoed out this $google_map_api_key = get_option(‘talimi_mapapi’); and its working fine. try in functions.php add require_once get_template_directory() . ‘/page-templates/theme-settings.php’; or add wp-load.php in your file. if you are using multi-site then try <?php get_site_option( $option, $default , $use_cache ) ?> reference https://codex.wordpress.org/Function_Reference/get_site_option
Nevermind, I figured it out. Here’s what I did in case anybody else wants to know. In my main php file in the plugin directory, I just added the following: if (get_option(‘new_option_name’) == ‘true’) { require_once plugin_dir_path(__FILE__) . ‘includes/theme/functions/add_id_user_admin.php’; }
Here is the function I used to solve the problem function username_editor_roles_callback() { global $wp_roles; $roles = $wp_roles->roles; foreach ($roles as $role) { $roleName = $role[‘name’]; $output = sprintf(‘<input type=”checkbox” id=”ue_roles_checkbox” name=”username_editor_settings[ue_roles_confirm][]” value=”%1$s” %2$s><label for=”ue_roles_checkbox”>%1$s</label><br>’, $roleName, checked( in_array($roleName, (array) ue_settings_option()[“ue_roles_confirm”]), 1, false ) ); echo $output; } }
update_option() passing empty array() but still updating
Okey I got it. I was close the whole time 🙂 function weborder_leveranstext_render( ) { $options = get_option( ‘weborder_settings’ ); global $wp_roles; $all_roles = $wp_roles->get_names(); foreach ($all_roles as $role => $value) { echo ‘<br><span style=”width: 180px; display: inline-block;”>’ . $value . ‘</span>’; echo ‘<input type=”text” style=”width: 300px;” name=”weborder_settings[weborder_leveranstext][‘.$role.’]” value=”‘.$options[‘weborder_leveranstext’][$role].'”>’; } }
I finally found a solution that works for me which I want to share with you. It’s more or less what EHerman posted here, I just made some little changes to adapt the code to my case. Basicly the idea is to find out that the upload comes from my admin page. This is done … Read more