Adding Capabilities to Default WordPress Roles

WordPress includes several default user roles, each with its own set of capabilities. These capabilities are the cornerstone of permissions in WordPress and provide easy privilege checking:

if (current_user_can('do_some_capabilitiy')) {
    // Do something that only certain users can do
}

The default capabilities are used by WordPress itself to control which settings and functions each user has access to. Only administrators, for example, can change theme options—which include background images, header images, widgets, etc.

Sometimes the defaults don't quit fit, though, and you'll want to add just one or two permissions to a role that doesn't have them without granting the whole slew of capabilities provided by the next role up.

Adding capabilities to default roles

The easiest way to add capabilities to a default role is through the user_has_cap filter, which is called whenever a capability test is performed (e.g. when current_user_can() is called).

The following example demonstrates how to give editors the ability to change theme options:

function modify_user_capabilities($capabilities, $capability)
{
    switch ($capability[0]) {
        case 'edit_theme_options':
            // Allow editors to change theme options
            if ((!array_key_exists('edit_theme_options', $capabilities) || !$capabilities['edit_theme_options']) && array_key_exists('editor', $capabilities) && $capabilities['editor'] == 1) {

                 $capabilities['edit_theme_options'] = true;
            }
    }
    return $capabilities;
}
add_filter('user_has_cap', 'modify_user_capabilities', 10, 2);
Look here for more information on WordPress filters.