Title: set_role
Last modified: August 19, 2016

---

# set_role

 *  Resolved [davidspan](https://wordpress.org/support/users/davidspan/)
 * (@davidspan)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/set_role/)
 * When I try to set role:
 * $user_id->set_role(‘contributor’);
 * I get this error:
    Fatal error: Call to a member function set_role() on a non-
   object in…
 * What am I missing?

Viewing 1 replies (of 1 total)

 *  Thread Starter [davidspan](https://wordpress.org/support/users/davidspan/)
 * (@davidspan)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/set_role/#post-734277)
 * Ok I found problem, I was missing this
    $user_id_role = new WP_User($user_id);
 * then changed this
    $user_id_role->set_role(‘contributor’);

Viewing 1 replies (of 1 total)

The topic ‘set_role’ is closed to new replies.

## Tags

 * [non object](https://wordpress.org/support/topic-tag/non-object/)
 * [set_role](https://wordpress.org/support/topic-tag/set_role/)

 * 1 reply
 * 1 participant
 * Last reply from: [davidspan](https://wordpress.org/support/users/davidspan/)
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/set_role/#post-734277)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
