how to give a user a role?

How possible give a user the ‘adminstrator’ role? for example I made a user with wp_insert_user(array(…, ‘role’ => ‘Administrator’) but it doesn’t effect on role of user.
thanks.

Related posts

1 comment

  1. enter image description here

    or

    / NOTE: Of course change 3 to the appropriate user ID
    $u = new WP_User( 3 );
    
    // Remove role
    $u->remove_role( 'subscriber' );
    
    // Add role
    $u->add_role( 'editor' );
    

    Super Admin – somebody with access to the site network administration features and all other features. See the Create a Network article.

    Administrator – somebody who has access to all the administration features within a single site.

    Editor – somebody who can publish and manage posts including the posts of other users.

    Author – somebody who can publish and manage their own posts.

    Contributor – somebody who can write and manage their own posts but cannot publish them.

    Subscriber – somebody who can only manage their profile.

Comments are closed.