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()?
- Where to store plugin settings fields
- Add on the fly tabs to plugin options
- What’s the best method for emptying an option created with the Settings API?
- Settings API – easiest way of validating checkboxes?
- Add_settings_field() parameterizing callback?
- Set a Default Value for an Option?
- How to change the file upload directory on version 3.5?
- Can I use the different settings sections over different pages using the save options group?
- get_option & update_option for multiple input fields with same name
- How to display usermeta on front end of site
- Is there a capability for managing plugin options?
- How to create a drop down list with pages to a themes options page?
- Settings API not saving values to database
- Transients API conditional
- How to use a newly registered setting with a checkbox and the default value ‘true’
- Is there any other place – besides a theme, a plugin, or a mu-plugin – that an option page might conceivably be used?
- Can I use register_settings and unregister_setting once the settings page has loaded?
- Issue on Checkbox with Custom Option Page
- Which Hook can I use when creating unique post but not update/save/delete
- Settings API: Setting default option via ‘get_option’ fails
- How to use update_option() without replacing/losing the old value?
- Create a counter variable in wp_options that increments when submit button is pressed
- What could cause a WP Option to get truncated?
- WordPress Settings API settings not saving for some users
- Sharing Buttons not Working – Sharing Settings [closed]
- Character \ appearing before ‘ after saving a settings page
- Settings API no update status? (refering to the yellow bar when you save settings)
- PHP class to add pages and fields in admin panel
- How to save Setting pages data to the database?
- get_option() and update_option() in a transaction (for an autoincrement value)
- display category name based on its equivalent id
- Call require_once form admin page with checkbox
- Encoding matter – ? instead of € after settings field callback
- How to save the option’s new values plus old value without overwrite old one
- How do I add a textarea (multirow) option to my WordPress plugin?
- Repeatable option fields not saving
- Settings API retrieving options database information alongside with user information?
- Option does not save or update upon page refresh
- WordPress theme options tabs
- Importing WP settings to another host
- Only show theme option if it option exists
- The issue of redirecting my site to a new domain
- If Home Page Do Nothing, If All Else Show This Content
- move setting data from wordpress api to codestar freamwork