set_role has no effect
You can use wp_update_user to update the role for your newly created user. if ( !username_exists( ‘mytestuser’ ) ) { $user_id = wp_create_user(‘mytestuser’, ‘testpass345′,’[email protected]’); $user_id = wp_update_user( array( ‘ID’ => $user_id, ‘role’ => ‘author’ ) ); } Further reading at WordPress Codex. Or, you can remove the current role and assign a new one: if … Read more