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;
}
}
Related Posts:
- How to retrieve the options from this options page?
- How to pass arguments from add_settings_field() to the callback function?
- How to pass variable to add_settings_section() callback?
- Difference between Option_Group and Option_Name in Register_Settings
- Settings API – creating reusable form elements?
- Settings API – changing add_settings_field() output?
- register_setting() vs add_option()
- Settings API – save an array of options as one setting (array_push?)
- Setting ‘autoload’ to ‘no’ with Settings API
- How to Save Different Settings Options Using Settings API and/or the Theme Optimizer
- Serialized settings in rest api
- Can’t output do_settings_sections . Can’t understand why
- Settings API – how to update multiple options manually?
- Single callback with multiple setting fields
- Settings API – how to update options manually?
- how can I detect that option value has changed?
- How to display some settings for super admin user only using Settings API
- Performance of several get_option() calls
- Settings API – input always updates over validation
- Is there a limit to the number of options you can store in one settings field of wp_options?
- Settings API get_option best practices
- Custom theme options Radio inputs not saving
- Settings API: Change position of custom setting field
- Tab from Settings API resetting all options with INSERT INTO [closed]
- Getting settings saved two times in settings page with tab
- get_option array value defaults and best practices
- WordPress setting with select – where is my mistake?
- The Settings API – What is the purpose of default value in register_setting?
- settings_fields doesn’t appear to be running
- Settings API – Separating PHP and HTML
- Two settings_fields in one form
- Settings API validation callback
- How to save custom settings api fields with custom section fuction
- Add description to custom plugin setting
- Settings API and ‘type’ => ‘font’
- ‘delete_option()’ only deleting the value, not the key/value pair
- How to add a Reset to Defaults button with Settings API?
- Save Plugin Options as Array
- Retrieve my custom settings in the settings/ API endpoint
- Is it possible to have a global parameter page which allows to configure other plugins in the same place?
- Is there a standard technique or API for getting the site header image?
- Help to create the best plugin settings!
- How to save Checkbox-Options in Plugin Options Page
- Problem with checkbox in Settings API
- Options saved and called in wrong order
- User specific settings, limited by role
- Access saved Options / Settings
- Dynamically Update Key in Associative Array When Saving Settings
- Incorporating the Settings API in WordPress Themes – by Chip Bennet
- How to add options for Pages?
- options validator input is false?
- Best place to store company address
- Where to adjust presets for slider options “auto rotate” (3, 5, 10, 15 seconds)? [closed]
- change backend header options
- Ignore “empty” fields when saving
- What is the real purpose of the parameter $option_group in the function register_setting()?
- Allow users to manage some options without granting ‘manage_options’ capability
- Are transients garbage collected?
- Add multiple custom fields to the general settings page
- Are all options loaded to memory on each request?
- How does object caching work?
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- How to use checkbox and radio button in options page?
- how to update serialized options programatically?
- Is get_option function cached?
- Performance with autoload and the options table
- What’s the difference between Options & Settings?
- Using widget options ‘outside’ the widget
- What are the advantages to the Settings API?
- How to load WordPress on non WP page?
- Where to store plugin settings fields
- Options for CDN with WordPress Including Supporting Plugins?
- Option to set static front page disappeared from admin reading settings
- WordPress Settings API, Implementing Tabs On Custom Menu Page
- How to set up default values for a plugin?
- Add on the fly tabs to plugin options
- Why does WordPress use serialize rather than json_encode for the options table? [duplicate]
- Plugin options will not save in database
- What’s the best method for emptying an option created with the Settings API?
- Settings API – easiest way of validating checkboxes?
- No option to allow search engines to index my site in WP 4.3
- How to update an ‘array’ option using wp-cli [duplicate]
- Plugin options autoloading
- How to Create a Custom WordPress Install Package?
- add static page to reading settings for custom post type
- Confirmation before deleting plugin options via uninstall.php
- Efficient way of saving plugin options
- Set WordPress settings programmatically
- How to display an admin notice after updating plugin settings?
- Fallback when Transient API fails
- Submenu pages delete settings from options array when saved
- get_option() from another wordpress site
- How can I get all user options?
- Where to hook register_settings for Settings API when also want to update options outside of Settings API?
- Add_settings_field() parameterizing callback?
- How much string content can I store in an option?
- Save and retrieve custom plugin options value
- How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
- Custom plugin settings: clicking “save changes” does not display success message
- Set a Default Value for an Option?