<?php
$user_data = array(
'user_login' => 'testuser',
'user_pass' => 'testpassword123!',
'user_email' => 'testuser@example.com',
'first_name' => 'Test',
'last_name' => 'User',
'role' => 'subscriber' // 역할을 구독자로 지정
);
$user_id = wp_insert_user( $user_data );
// 사용자 생성 성공 여부 확인
if ( is_wp_error( $user_id ) ) {
// 오류 발생 시 오류 메시지 출력
$error_message = $user_id->get_error_message();
echo "사용자 생성 오류: " . $error_message;
} else {
// 성공 시 사용자 ID 출력
echo "사용자가 성공적으로 생성되었습니다. 사용자 ID: " . $user_id;
}
?>
$userdata = array(
'ID' => 0, //(int) User ID. If supplied, the user will be updated.
'user_pass' => '', //(string) The plain-text user password.
'user_login' => '', //(string) The user's login username.
'user_nicename' => '', //(string) The URL-friendly user name.
'user_url' => '', //(string) The user URL.
'user_email' => '', //(string) The user email address.
'display_name' => '', //(string) The user's display name. Default is the user's username.
'nickname' => '', //(string) The user's nickname. Default is the user's username.
'first_name' => '', //(string) The user's first name. For new users, will be used to build the first part of the user's display name if $display_name is not specified.
'last_name' => '', //(string) The user's last name. For new users, will be used to build the second part of the user's display name if $display_name is not specified.
'description' => '', //(string) The user's biographical description.
'rich_editing' => '', //(string|bool) Whether to enable the rich-editor for the user. False if not empty.
'syntax_highlighting' => '', //(string|bool) Whether to enable the rich code editor for the user. False if not empty.
'comment_shortcuts' => '', //(string|bool) Whether to enable comment moderation keyboard shortcuts for the user. Default false.
'admin_color' => '', //(string) Admin color scheme for the user. Default 'fresh'.
'use_ssl' => '', //(bool) Whether the user should always access the admin over https. Default false.
'user_registered' => '', //(string) Date the user registered. Format is 'Y-m-d H:i:s'.
'show_admin_bar_front' => '', //(string|bool) Whether to display the Admin Bar for the user on the site's front end. Default true.
'role' => '', //(string) User's role.
'locale' => '', //(string) User's locale. Default empty.
);