add_existing_user_to_blog()添加用户到当前博客(多站点)

目录

描述

Add a user to the current blog based on details from maybe_add_existing_user_to_blog().

Note: This function is called by maybe_add_existing_user_to_blog() and should not be called directly. This page is for informational purposes only. Use add_user_to_blog().

add_existing_user_to_blog() 描述

用法

<?php add_existing_user_to_blog$details ?>

add_existing_user_to_blog() 用法

参数

$details

(array) (可选) Must at least contain values for the keys listed below

默认值: false (which will cause a failure)

  • $details['user_id'] - (integer) the ID of the user being added to the current blog
  • $details['role'] - (string) the role to be assigned to the user in the current blog

add_existing_user_to_blog() 参数

注意

add_existing_user_to_blog() 注意

历史

添加于 版本: MU ( 3.0.0)

add_existing_user_to_blog() 历史

源文件

add_existing_user_to_blog() 函数的代码位于 wp-includes/ms-functions.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU
 *
 * @global int $blog_id
 *
 * @param array $details
 * @return true|WP_Error|void
 */
function add_existing_user_to_blog( $details = false ) {
	global $blog_id;

	if ( is_array( $details ) ) {
		$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
		 *
		 * @param int   $user_id User ID.
		 * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
		 */
		do_action( 'added_existing_user', $details['user_id'], $result );
		return $result;
	}
}

add_existing_user_to_blog() 源文件

相关