Multiple checkbox doesn’t work in wordpress settings api

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; } }

Save Plugin Options as Array

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].'”>’; } }

How to load WordPress on non WP page?

The shortest way is to load wp-load.php and abort the loading of the template engine (Note: You couldn’t do that, if you’d be loading the header file, like you see it on many sites in the interweb). # No need for the template engine define( ‘WP_USE_THEMES’, false ); # Load WordPress Core // Assuming we’re … Read more

Option value not get saved in the database

The option value is not being saved in the database because, as you could see below, the registered option name is num_of_columns and not num_of_cols: // The second parameter is the option name. register_setting( ‘purchase-history-grid’, ‘num_of_columns’ ); So make sure that you use the correct option name in your settings field callback: Use get_option( ‘num_of_columns’ … Read more

How to change color of a word in text after WP update

There is no such option in WordPress, you will need to consult the 3rd party plugins you have installed to identify the plugin that provided it then contact their support. But you shouldn’t need it, as WordPress already provides this feature, and it’s visible in your screenshot as highlight: Which brings up a colour picker: