add_role example


function add_role( $role$display_name$capabilities = array() ) {
    if ( empty( $role ) ) {
        return;
    }

    return wp_roles()->add_role( $role$display_name$capabilities );
}

/** * Removes a role, if it exists. * * @since 2.0.0 * * @param string $role Role name. */
function remove_role( $role ) {
    wp_roles()->remove_role( $role );
}
populate_roles_280();
    populate_roles_300();
}

/** * Create the roles for WordPress 2.0 * * @since 2.0.0 */
function populate_roles_160() {
    // Add roles.     add_role( 'administrator', 'Administrator' );
    add_role( 'editor', 'Editor' );
    add_role( 'author', 'Author' );
    add_role( 'contributor', 'Contributor' );
    add_role( 'subscriber', 'Subscriber' );

    // Add caps for Administrator role.     $role = get_role( 'administrator' );
    $role->add_cap( 'switch_themes' );
    $role->add_cap( 'edit_themes' );
    $role->add_cap( 'activate_plugins' );
    $role->add_cap( 'edit_plugins' );
    
Home | Imprint | This part of the site doesn't use cookies.