WordPress開發(fā)函數(shù)add_existing_user_to_blog()
WordPress開發(fā)函數(shù)add_existing_user_to_blog(),根據(jù)maybe_add_existing_user_to_blog()中的詳細信息向博客添加用戶。
用法:
add_existing_user_to_blog( array|false $details = false )
描述:
$details
(array|false) (可選) 用戶詳細信息。必須至少包含下面列出的鍵的值。
'user_id'
(int) 正在添加到當前博客的用戶的ID。
'role'
(string) 分配給用戶的角色。
默認值:false
返回:
(true|WP_Error|void) 如果用戶不存在或無法添加,則返回True;如果用戶不存在或無法添加,則返回WP_Error對象。如果$details數(shù)組沒有提供,則為空。
更多的信息
這個函數(shù)由maybe_add_existing_user_to_blog()調(diào)用,不應(yīng)該直接調(diào)用。本頁僅供參考之用。使用add_user_to_blog()。
來源:
文件: wp-includes/ms-functions.php
function add_existing_user_to_blog( $details = false ) {
if ( is_array( $details ) ) {
$blog_id = get_current_blog_id();
$result = add_user_to_blog( $blog_id, $details['user_id'], $details['role'] );
/**
* Fires immediately after an existing user is added to a site.
*
* @since MU (3.0.0)
*
* @param int $user_id User ID.
* @param true|WP_Error $result True on success or a WP_Error object if the user doesn't exist
* or could not be added.
*/
do_action( 'added_existing_user', $details['user_id'], $result );
return $result;
}
}