- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「関数リファレンス/wp update user」の版間の差分
細 (→解説: 最新の) |
(最新版のマージ) |
||
1行目: | 1行目: | ||
+ | {{NeedTrans}} | ||
<div id="Description"> | <div id="Description"> | ||
== 解説 == | == 解説 == | ||
13行目: | 14行目: | ||
注: If current user's password is being updated, then the cookies will be cleared! | 注: If current user's password is being updated, then the cookies will be cleared! | ||
− | === | + | ===特記事項=== |
<del>If <tt>$userdata</tt> does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned.</del> Since version 3.6 this is no longer the case, but this behavior may be restored in the future. See [https://core.trac.wordpress.org/ticket/16731 ticket #16731]. | <del>If <tt>$userdata</tt> does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned.</del> Since version 3.6 this is no longer the case, but this behavior may be restored in the future. See [https://core.trac.wordpress.org/ticket/16731 ticket #16731]. | ||
20行目: | 21行目: | ||
<div id="Usage"> | <div id="Usage"> | ||
− | == | + | == 使い方 == |
</div> | </div> | ||
<pre> | <pre> | ||
38行目: | 39行目: | ||
<div id="Examples"> | <div id="Examples"> | ||
− | == | + | == 用例 == |
</div> | </div> | ||
<!-- Need creative examples. Feel free to link to external examples. --> | <!-- Need creative examples. Feel free to link to external examples. --> | ||
165行目: | 166行目: | ||
<div id="Source File"> | <div id="Source File"> | ||
− | == | + | == ソースファイル == |
</div> | </div> | ||
<!-- Need links to current source code files --> | <!-- Need links to current source code files --> | ||
173行目: | 174行目: | ||
== 関連情報 == | == 関連情報 == | ||
</div> | </div> | ||
+ | |||
+ | {{Current User Tags}} | ||
+ | |||
<!-- | <!-- | ||
To Do: | To Do: | ||
180行目: | 184行目: | ||
--> | --> | ||
− | {{原文|Function_Reference/wp_update_user| | + | {{原文|Function_Reference/wp_update_user|151538}} <!-- 01:09, 12 May 2015 Miccweb 版 --> |
[[Category:関数リファレンス]] | [[Category:関数リファレンス]] | ||
[[Category:関数]] | [[Category:関数]] | ||
[[Category:wp2.0]] | [[Category:wp2.0]] | ||
[[Category:wp3.5]] | [[Category:wp3.5]] |
2015年5月12日 (火) 10:19時点における版
このページ「関数リファレンス/wp update user」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
データベースのユーザーを更新します。
この関数は、データベース内の1つのユーザーを更新します。このアップデートでは、配列としてユーザメタデータの複数の部分を含めることができます。
To update a single piece of user metadata, use update_user_meta() instead.
To create a new user, use wp_insert_user() instead.
注: If current user's password is being updated, then the cookies will be cleared!
特記事項
If $userdata does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned. Since version 3.6 this is no longer the case, but this behavior may be restored in the future. See ticket #16731.
使い方
<?php wp_update_user( $userdata ) ?>
パラメータ
- $userdata
- (mixed) (必須) An array of user data, stdClass or WP_User object.
- 初期値: なし
戻り値
- (mixed)
- If successful, returns the user_id, otherwise returns a WP_Error object.
用例
Below is an example showing how to update a user's Website profile field
<?php $user_id = 1; $website = 'http://wordpress.org'; $user_id = wp_update_user( array( 'ID' => $user_id, 'user_url' => $website ) ); if ( is_wp_error( $user_id ) ) { // There was an error, probably that user doesn't exist. } else { // Success! }
注
以下は内部で使用している関数です。
- Uses: get_userdata()
- Uses: wp_hash_password()
- Uses: wp_insert_user() ユーザーを更新したり、存在しない場合に作成するために使われます。
- Uses: wp_get_current_user()
- Uses: wp_clear_auth_cookie()
- Uses: wp_set_auth_cookie()
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. Please note that the function cannot alter this field, since WordPress does not allow usernames to be changed. | 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) |
show_admin_bar_front | Show the WP admin bar on the front-end. | (none) |
Remember, user_pass should be the plain text password as it will be automatically hashed by WordPress.
改訂履歴
2.0.0: 導入されました。 3.5.0: stdClassまたはWP_Userオブジェクトを受け取ります。
ソースファイル
wp_update_user()はwp-includes/registration.phpにあります。
関連情報
カレントユーザー関数: get_current_user_id()/ en, get_currentuserinfo(), wp_get_current_user()/ en, wp_set_current_user(), current_user_can(), current_user_can_for_blog()/ en
最新英語版: WordPress Codex » Function_Reference/wp_update_user (最新版との差分)