概要
wp_create_user
関数は、WordPress のサイトに新しいユーザーを追加するための関数です。この関数は、ユーザー登録やカスタムユーザープロフィールの作成時に役立ちます。具体的には以下のような機能を実装する際によく使われます。
- ウェブサイトへの新規登録ユーザーの追加
- ユーザー管理画面からの新規ユーザー作成
- プラグインやテーマの設定における自動ユーザー登録
- ユーザーのバルク追加(CSVなどからのインポート)
- カスタムユーザー登録フォームの実装
- APIを通じたユーザーレジストレーション
- ショッピングサイトにおける新規会員登録
- フロントエンドでのユーザーアカウント作成
構文
wp_create_user( $username, $password, $email );
パラメータ
$username
(string) 必須: 新しいユーザーのユーザー名。$password
(string) 必須: 新しいユーザーのパスワード。$email
(string) 必須: 新しいユーザーのメールアドレス。
戻り値
- 成功した場合は新しいユーザーのIDを返します。
- 失敗した場合はWP_Errorオブジェクトを返します。
関連する関数
- https://refwp.com/?titleonly=1&s=wp_delete_user
- https://refwp.com/?titleonly=1&s=wp_update_user
- https://refwp.com/?titleonly=1&s=wp_get_current_user
使用可能なバージョン
wp_create_user
関数は WordPress 2.0 以降で利用可能です。
コアファイルのパス
wp-includes/user.php
この関数のアクションでの使用可能性
アクション | 使用可能性 |
---|---|
mu_plugin_loaded | 〇 |
registered_post_type | |
plugins_loaded | 〇 |
wp_roles_init | |
setup_theme | |
after_setup_theme | |
set_current_user | 〇 |
init | 〇 |
register_sidebar | |
wp_loaded | 〇 |
send_headers | |
parse_query | |
pre_get_posts | |
wp | 〇 |
template_redirect | |
get_header | |
wp_head |
非推奨または削除されたバージョン
特に非推奨または削除されたバージョンはありません。