Hoàng Web

Thiết Kế Website WordPress

  • Kho giao diện
  • Dịch Vụ
    • Thiết kế web giá rẻ
    • Thiết kế website WordPress
    • Hosting Miễn Phí 100GB
    • Tích hợp thanh toán MoMo, ViettelPay, Vietcombank, MB..
    • Tối ưu Google PageSpeed
    • Sửa lỗi nâng cấp website
    • Viết plugin WordPress
    • Code Tool theo yêu cầu
  • Bảng giá
  • Quy trình làm việc
  • Giới thiệu
  • Liên Lạc
Trang chủ » Wordpress » Tạo user trong wordpress

Tạo user trong wordpress

Thứ Năm, 03/07/2014 by Hoàng Quách

  • shares
  • Facebook
  • Facebook Messenger
  • Gmail
  • Viber
  • Skype

Thêm người dùng vào CSDL:
Cú pháp: wp_insert_user($userdata);

$userdata: mảng dữ liệu user, stdClass hoặc đối tượng lớp WP_User.

$website = "http://codechutney.com"
$userdata = array(
    'user_login'    =>  'login_name',
    'user_nicename'  =>'Mr Hoang',
    'display_name'  => 'display name',
    'user_url'  => $website,
    'user_email' =>'[email protected]',
    'user_pass'=>wp_hash_password('123456')
);

$user_id = wp_insert_user( $userdata ) ;

//On success
if( !is_wp_error($user_id) ) {
 echo "User created : ". $user_id;
}

Bạn cũng có thể thay đổi mật khẩu sau khi tạo người dùng, với hàm sau:

wp_set_password('plaintext new user password',$user_id);

Biến $userdata chứa các trường thông tin dưới đây:
nickname,fist_name,last_name,discription,role,jabber,aim,yim..

Chi tiết:

The $userdata array can contain the following fields
Field Name Description Associated Filter
ID An integer that will be used for updating an existing user. (none)
user_pass A string that contains the plain text password for the user. pre_user_pass
user_login A string that contains the user’s username for logging in. pre_user_login
user_nicename A string that contains a URL-friendly name for the user. The default is the user’s username. pre_user_nicename
user_url A string containing the user’s URL for the user’s web site. pre_user_url
user_email A string containing the user’s email address. pre_user_email
display_name A string that will be shown on the site. Defaults to user’s username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user). pre_user_display_name
nickname The user’s nickname, defaults to the user’s username. pre_user_nickname
first_name The user’s first name. pre_user_first_name
last_name The user’s last name. pre_user_last_name
description A string containing content about the user. pre_user_description
rich_editing A string for whether to enable the rich editor or not. False if not empty. (none)
user_registered The date the user registered. Format is Y-m-d H:i:s. (none)
role A string used to set the user’s role. (none)
jabber User’s Jabber account. (none)
aim User’s AOL IM account. (none)
yim User’s Yahoo IM account. (none)

Nếu không tồn tại ID, một user mới sẽ được tạo. Nếu bạn truyền giá trị ID hàm sẽ cập nhật dữ liệu cho người dùng đã tồn tại trong WordPress.

Để nhận được bài viết mới vui lòng đăng ký kênh kiến thức WordPress từ A-Z ở Form bên dưới. Bạn cũng có thể nhận được sự trợ giúp trên Twitter và Facebook

  • shares
  • Facebook
  • Facebook Messenger
  • Gmail
  • Viber
  • Skype

Chuyên mục: Wordpress Tìm kiếm: registry account

Tôi giúp gì cho bạn?

HOÀNG WEB

Địa chỉ: Tây Sơn, Phường Quang Trung, Quận Đống Đa, Hà Nội

Hotline: 0987 342 124 – 0868 292 303 (8h:00 – 21h:00)

Email: [email protected]

Website: www.hoangweb.com

KẾT NỐI VỚI TÔI

  • Facebook
  • GitHub
  • YouTube

SẢN PHẨM

  • Plugin Thanh Toán Quét Mã QR Code Tự Động
  • WP2Speed – Tối ưu Google Speed
  • 23WebHost – Hosting Miễn Phí 100GB

LIÊN KẾT

  • Có nên thuê thiết kế website giá rẻ?
  • Hướng dẫn thanh toán
  • Chính sách hoàn tiền
  • Trung tâm hỗ trợ

Copyright © 2023 | All rights reserved | HOANG WEB
Mọi hình thức sao chép nội dung trên website này mà chưa được sự đồng ý đều là trái phép.