Nội dung
Có rất nhiều cách để bạn thực hiện tạo mới một user WordPress và phân quyền cho user, như tạo mới từ trang quản trị admin WordPress, tạo trong phpMyAdmin hoặc tạo mới từ file functions.php trong themes.
Và cách ngày hôm nay mình sẽ hướng dẫn bạn tạo bằng WP CLI rất đơn giản như sau.
Bước 1: Truy cập vào Terminal

Bước 2: cd vào thư mục website cần tạo user
Ở đây mình muốn tạo user mới cho website linuxcanban.com . Mình sẽ truy cập vào thư mục chưa mã nguồn linuxcanban.com bằng lệnh cd
Lưu ý:
- Với domain chính (Primary Domain) thư mục chứa mã nguồn sẽ là public_html
- Với domain addon: thư mục chứa mã nguồn sẽ nằm trong thư mục mang tên domain (nếu ban đầu ban không thay đổi)

Bước 3: Tạo user
Sau khi đã truy cập vào được thư mục chưa mã nguồn website cần tạo user, bạn tiến hành nhập lệnh sau để tạo mới user
wp user create usercantao emailtheouser --role=administrator
VD: wp user create dotrungquan dotrungquan@linuxcanban.com – -role=administrator
Chú thích
- wp user create : lệnh tạo user
- dotrungquan : tên user cần tạo
- dotrungquan@linuxcanban.com : email quản lý user đó
- –role=administrator : quyền của user
- Ngoài quyền administrator còn có các quyền như: ‘administrator’, ‘editor’, ‘author’, ‘contributor’,
Sau khi tao user xong hệ thống sẽ tự tạo password mới như mục số 2 trong ảnh.

Bạn có thể kiểm tra lại bằng cách list user ra xem bằng lệnh wp user list

Chúc các bạn thành công.