blob: 9942a0f2d42c9233cd99c70655dcf9650b1bcad9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
class UserWrapper {
public $userName;
public $password;
public $user;
public function __construct( $userName, $password, $group = '' ) {
$this->userName = $userName;
$this->password = $password;
$this->user = User::newFromName( $this->userName );
if ( !$this->user->getId() ) {
$this->user = User::createNew( $this->userName, [
"email" => "test@example.com",
"real_name" => "Test User" ] );
}
TestUser::setPasswordForUser( $this->user, $this->password );
if ( $group !== '' ) {
$this->user->addGroup( $group );
}
$this->user->saveSettings();
}
}
|