capability

Can't find what you're looking for? Check the github issues or edit this page to add what's missing.

The capability argument allows you to define the the capability that a user must have in order to access the control for a field.

If left undefined it defaults to edit_theme_options.

You can set the capability in your config, as well as on individual fields.

Example:

<?php
// Only allow network admins to access options in this config
Kirki::add_config( 'my_config', [
	'option_type' => 'theme_mod',
	'capability'  => 'manage_network_plugins'
];

// Add a simple text-field.
// This will inherit the capability from our config.
Kirki::add_field( 'my_config', [
	'type'     => 'text',
	'settings' => 'my_setting1',
	'label'    => esc_html__( 'Text Control 1', 'my_textdomain' ),
	'section'  => 'my_section',
	'default'  => esc_html__( 'This is a default value', 'my_textdomain' ),
	'priority' => 10,
] );

// Another text-field.
// This will override the capability of the config and be available to admins.
Kirki::add_field( 'my_config', [
	'type'        => 'text',
	'settings'    => 'my_setting2',
	'label'       => esc_html__( 'Text Control 2', 'my_textdomain' ),
	'section'     => 'my_section',
	'default'     => esc_html__( 'This is a default value', 'my_textdomain' ),
	'priority'    => 10,
	'capability'  => 'edit_theme_options'
] );
?>

For a complete list of WordPress capabilities and what capabilities each user role has, please visit the documentation on wordpress.org.

Edit this page