I am working on a page within a WordPress multisite install.

I am using wp_insert_user() to add users. I need to do this programmatically.

The problem I have is with the roles. Every time I create a user, all roles are added to this user. It seems to happen both when I don't specify a role and when I specify only one role.

Does anyone know why this is happening? Is this the default behavior when adding new users?

  • can you show us your code? It's very difficult to diagnose code issues blind, edit your question to include it
    – Tom J Nowell
    Jul 5, 2017 at 18:55

1 Answer 1


You need to update the user straight after they have been created. So yes, by default they get all then you update.

wp_update_user( array ('ID' => $user_id, 'role' => 'user_role_here') );

The above should fix this issue.

Obviously changing the $user_id to your style of ID and also user_role_here to editor or alike.

Thanks, Tom


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.